Partitions a sequence into groups linearly by predicate. I use this for breaking up my lazy record parsing with sequences into entity-sized chunks which are then easily digestible. Note: Edited back from the previous edit as these were heavily profiled and yield! tends to be slow. Edit #2: Now correctly using "use" instead of "let" for sequence.GetEnumerator () (Thanks Vladimir Matveev)
1 people like thisPosted: 13 years ago by Rick Minerich
Take a sequence and make it into a sequence of sequences, where the inner sequences are of a specified length. (The last inner sequence may be shorter.) Useful, for instance, for rending sequences into two-way HTML grids.
1 people like thisPosted: 12 years ago by Kit Eason
This snippet declares a function that operates on lists that groups elements of a sequence while the predicate holds. A new group is started for an element when the predicate no longer holds. The predicate is passed the current element and the previous element. This implementation is likely not very efficient.
0 people like thisPosted: 5 years ago by Matthew Rodatus
This snippet is basically the same as http://fssnip.net/6A, except that the element whose predicate holds ends the previous group and the element after it starts a new one. Those two snippets (Seq.groupWhen, Seq.groupAfter) would be generally equivalent to the Haskell functions 'breakBefore' and 'breakAfter' from Data.List.Grouping.
0 people like thisPosted: 13 years ago by Thorsten Meinecke
The snippet declares a function that groups adjacent elements of a sequence. A new group is started when the specified predicate holds about an element. Groups are constructed eagerly (using lists).
2 people like thisPosted: 8 years ago by Tomas Petricek