Snippets tagged partition

  • Partition a sequence until a predicate is satiated

    This function is given a partition predicate and a sequence. Until the predicate returns false, a list will be filled with elements. When it is, both the list and the remainder of the sequence will be returned. Note that this example preserves the laziness of the unchecked sequence elements.

    69 people like this

    Posted: 13 years ago by Rick Minerich

  • Partition a list

    The snippet implements 'List.partitionWhile' which behaves as a combination of 'Seq.takeWhile' and 'Seq.skipWhile': It splits the list into a part containing elements from the beginning of a list that match a given predicate and remaining elements.

    7 people like this

    Posted: 11 years ago by Tomas Petricek

  • Split a list

    Three ways to split a list in half (but not necessarily in the middle). A forth version added that's very short and should be fast, as we only use List.fold. New champ found.

    80 people like this

    Posted: 13 years ago by Dmitri Pavlenkov

  • List Multipartition

    Needed to partition a list into multiple groups, but couldn't find an existing way to do it. Have not put this as an extension method as needed it in an .fsx file which is loaded, but couldn't get extension method to work from that.

    1 people like this

    Posted: 9 years ago by @BrockSamsonUK