Recent snippets

  • Null Value guard active pattern

    An active pattern that protects from null reference exceptions stemming from pattern matches on values materialized by .NET libraries such as Newtonsoft.Json

    0 people like this

    Posted: 11 hours ago by Eirik Tsarpalis

  • Creating a list of all the elements of an Enum

    I have seen a few postings on the web about this, with not terribly elegant solutions. Here is how I do it.

    1 people like this

    Posted: 8 days ago by billhay

  • 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: 8 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: 13 days ago by Tuomas Hietanen

  • ResultBuilder Computational Expression

    Computational Expression for Result<'a, 'b>

    3 people like this

    Posted: 22 days ago by Yuriy Habarov

  • Test string is all UpperCase 2

    There is another "All Uppercase" snippet that does two searches - one to verify that there's at least one upper case letter and one to make sure there are no lowercase letters. "---D" is "uppercase" but "---" is not. I wanted to duplicate that behavior even though it seems a bit questionable, but do it in one regex search. The underappreciated lookahead features of RegEx allow this sort of thing - scanning forward and then rescanning forward so I use that here

    1 people like this

    Posted: 25 days ago by Darrell Plank

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

    78 people like this

    Posted: 7 years ago by Novox

  • Hello world (F#)

    Classical "Hello world" example that prints a message to the console output. This version uses F# printfn function to do the printing.

    178 people like this

    Posted: 7 years ago by Tomas Petricek

  • Implementing active objects with a MailboxProcessor

    Mailbox processors can easily be used to implement active objects. This example shows how to do that with a reusable wrapper type and minimal boilerplate code in the actual class definitions. Supports both asynchronous calls and synchronous calls. For the latter case, exceptions are automatically propagated back to the caller.

    90 people like this

    Posted: 7 years ago by Wolfgang Meyer

Snippets by tags

kata (17) monad (20) recursion (27) json (12) game (30) pattern matching (12) async (92) silverlight (21) list (49) parsing (22) html (14) collections (16) sequence (29) xml (12) reflection (18) dsl (22) wpf (19) seq (51) fold (19) f# (42)

View all...

Database contains 2215 snippets out of which 1515 is public.