Recent snippets

Popular snippets

  • Chain of responsibility

    The following sample wants to make sure the person’s age is between 18 and 65, weight is no more than 200 and tall enough (>120).

    80 people like this

    Posted: 10 years ago by Tao Liu

  • Units of Measure

    Show's how to define units of measure to add stronger typing to your numerical functions.

    75 people like this

    Posted: 10 years ago by Robert Pickering

  • FSX Structure

    I use this basic template when writing .fsx files that I might want to compile. It adjusts the difference in command line/entrypoint handling between a script and a compiled assembly. This example shows the details for a WPF script — replace the #r's and/or remove the STAThread for a WinForms or Console script.

    120 people like this

    Posted: 10 years ago by Blake Coverett

  • Asynchronous sequences

    An asynchronous sequence is similar to the seq type, but the elements of the sequence are generated asynchronously without blocking the caller as in Async. This snippet declares asynchronous sequence and uses it to compare two files in 1k blocks.

    109 people like this

    Posted: 10 years ago by Tomas Petricek

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

    68 people like this

    Posted: 10 years ago by Rick Minerich

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

    80 people like this

    Posted: 10 years ago by Novox

Snippets by tags

f# (44) tryfsharp (48) sequences (48) lazy (20) recursion (32) learning f# (16) json (14) collections (16) dsl (23) list (55) quotations (21) string (25) sequence (32) html (15) array (22) lists (14) reflection (19) design patterns (18) async (96) http (17)

View all...

Database contains 2839 snippets out of which 1665 is public.