Recent snippets

Popular snippets

  • Composing a list of functions

    Composition of functions in F# is easily achieved by using the >> operator. You can also chain an arbitary amount of functions (represented as a list or sequence) together by folding the list/seq with >>. [More formally: the set of endomorphisms 'a -> 'a forms a monoid with the binary, associative operator ">>" (or "<<") and the neutral element "id".]

    87 people like this

    Posted: 15 years ago by Novox

  • 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.

    74 people like this

    Posted: 15 years ago by Rick Minerich

  • Projecting lists

    Three functions showing how to implement projection for functional lists. First version uses naive recursion and the second one is tail-recursive using the accumulator parameter. The third version extends this with continuation passing.

    75 people like this

    Posted: 16 years ago by Tomas Petricek

Snippets by tags

list (56) algorithms (25) http (18) agent (20) parsing (28) tryfsharp (48) sequence (32) async (98) tutorial (17) lists (15) wpf (20) learning f# (16) kata (17) computation expression (15) computation builder (17) collections (16) game (32) design patterns (18) dsl (23) staging (18)

View all...

Database contains 3212 snippets out of which 1719 is public.