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

  • A beautiful fixed-point finding function

    We start with an initial value and then applying f repeatedly, until the value does not change anymore.

    303 people like this

    Posted: 15 years ago by Nick Palladinos

  • 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: 15 years ago by Alex Muscar

  • Creating objects with events

    This snippet shows how to create objects with events in F#. It shows both simple event (to be used from F#) and a .NET compatible event with specific delegate type.

    85 people like this

    Posted: 15 years ago by Tomas Petricek

  • Strategy pattern

    Strategy pattern in F#

    83 people like this

    Posted: 14 years ago by Tao Liu

  • Composable WCF Web API using Async

    A functional wrapper around the new WCF Web APIs (http://wcf.codeplex.com/). Composition is achieved through the use of the HttpRequestMessage -> Async signature. Pushing the app calls in the MessageHandler intercepts all requests and allows you to take control at the earliest point possible before operation selection occurs. Extending this slightly to call the innerChannel's SendAsync would allow you to create a middleware layer that would work both with this and other, normal Web API services.

    63 people like this

    Posted: 15 years ago by Ryan Riley

Snippets by tags

parsing (28) collections (16) array (22) agent (20) json (16) tutorial (17) recursion (33) quotations (21) computation builder (17) f# (43) math (35) reflection (19) seq (54) async (98) dsl (23) regex (17) silverlight (22) design patterns (18) fold (22) monad (24)

View all...

Database contains 3208 snippets out of which 1719 is public.