Snippets tagged grouping

  • Partition a sequence into groups linearly by predicate

    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 this

    Posted: 7 years ago by Rick Minerich

  • Transform a sequence into a sequence-of-sequences

    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 this

    Posted: 6 years ago by Kit Eason

  • Seq.groupAfter function

    This snippet is basically the same as, 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 this

    Posted: 6 years ago by Thorsten Meinecke

  • Seq.groupWhen function

    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 this

    Posted: 2 years ago by Tomas Petricek