Recent snippets

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

Popular snippets

  • The Haskell const function

    The const function is simple, but you can use it to make your code more legible. In this example we convert a unary function to a function of arity 2 (that ignores the second argument). Also by using the flip function from Haskell (which is equally easy to define) you can ignore the first argument.

    119 people like this

    Posted: 7 years ago by Alex Muscar

  • Continuation-Passing Mnemonics

    Continuations provide a means whereby heap space can be traded for stack depth (heap space being generally more plentiful than stack depth). They are especially useful where tail recursion is not possible. Here are a couple of simple continuation examples that can be extended to cover more complex scenarios.

    88 people like this

    Posted: 7 years ago by Neil Carrier

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

    75 people like this

    Posted: 6 years ago by Tao Liu

Snippets by tags

async (92) parsing (22) lists (13) staging (18) dsl (22) pattern matching (12) monad (20) learning f# (16) json (12) design patterns (18) reflection (18) tutorial (17) agent (20) math (32) string (20) silverlight (21) http (15) regex (14) kata (17) quotations (17)

View all...

Database contains 2214 snippets out of which 1514 is public.