Select the next N elements of an IEnumerable<T>
- by sassafrass
Say you've got some IEnumerable called S of length N. I would like to select all continuous subsequences of length n <= N from S.
If S were, say, a string, this'd be pretty easy. There are (S.Length - n + 1) subsequences of length n. For example, "abcdefg" is length (7), so that means it has (5) substrings of length (3): "abc", "bcd", "cde", "def", "efg".
But S could be any IEnumerable, so this route isn't open. How do I use extension methods to solve this?