Recent snippets

Popular snippets

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

    92 people like this

    Posted: 15 years ago by Wolfgang Meyer

  • NUnit Sugar

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

    91 people like this

    Posted: 15 years ago by Ryan Riley

  • 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

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

    74 people like this

    Posted: 15 years ago by Rick Minerich

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

    100 people like this

    Posted: 15 years ago by Neil Carrier

  • Chain of responsibility II

    Unlike the previous chain of responsibility, this version use the pipeline to chain responsibilities.

    106 people like this

    Posted: 14 years ago by Tao Liu

Snippets by tags

mailboxprocessor (27) math (35) recursion (33) computation expression (15) tutorial (17) silverlight (22) dsl (23) wpf (20) monad (24) html (16) http (18) json (16) lazy (20) staging (18) algorithms (25) list (56) learning f# (16) lists (15) game (32) parsing (28)

View all...

Database contains 3208 snippets out of which 1719 is public.