Recent snippets

  • Outer product (aka outer join) of n lists

    I recently wrote a program to automatically solve a category of logic puzzles, alone the lines of 'four men walked into a bar, one who drinks Guinness never pays darts...' The objective is to find a unique combination of attributes - name, age, favorite drink, favorite pub activity etc. I decided on a brute force approach, in which I generate every combination of attributes, apply a set of rules, and then inspect for the one unique solution. My solution starts with producing a list of lists of attributes.

    0 people like this

    Posted: 10 days ago by billhay

  • Decrypting a Rijndael string

    This F# code decrypts an encrypted string using Rijndael symmetric encryption algorithm. It uses key and initialization vector stored in a registry key.

    1 people like this

    Posted: 15 days ago by Tuomas Hietanen

  • ResultBuilder Computational Expression

    Computational Expression for Result<'a, 'b>

    3 people like this

    Posted: 24 days ago by Yuriy Habarov

Popular snippets

  • 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: 7 years ago by Rick Minerich

  • Filtering lists

    Two functions showing how to filter functional lists using the specified predicate. First version uses naive recursion and the second one is tail-recursive using the accumulator parameter.

    65 people like this

    Posted: 7 years ago by Tomas Petricek

  • Units of Measure

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

    74 people like this

    Posted: 7 years ago by Robert Pickering

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

    78 people like this

    Posted: 7 years ago by Novox

  • Factory Pattern

    Factory pattern in F#

    72 people like this

    Posted: 6 years ago by Tao Liu

  • NUnit Sugar

    Some simple functions for writing more idiomatic F# tests with NUnit.

    85 people like this

    Posted: 7 years ago by Ryan Riley

Snippets by tags

html (14) fparsec (14) quotations (17) algorithms (25) async (92) game (30) monad (20) silverlight (21) xml (12) lazy (18) fold (19) recursion (27) kata (17) math (32) design patterns (18) list (49) sequence (30) json (12) tutorial (17) mailboxprocessor (26)

View all...

Database contains 2216 snippets out of which 1516 is public.