F# Snippets

Recently added snippets

Popular snippets

  • A beautiful fixed-point finding function

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

    241 people like this
    Posted: 3 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.

    99 people like this
    Posted: 3 years ago by Alex Muscar

  • FSX Structure

    I use this basic template when writing .fsx files that I might want to compile. It adjusts the difference in command line/entrypoint handling between a script and a compiled assembly. This example shows the details for a WPF script — replace the #r's and/or remove the STAThread for a WinForms or Console script.

    93 people like this
    Posted: 3 years ago by Blake Coverett

  • Haskell function : iterate

    Implements iterate function from Haskell's Prelude. The function generates an infinite sequence by applying a function to the initial value (first) and then to the result of previous application.

    156 people like this
    Posted: 3 years ago by Nick Palladinos

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

    76 people like this
    Posted: 3 years ago by Wolfgang Meyer

  • Adapter pattern

    Invoke the methods from incompatible types

    92 people like this
    Posted: 2 years ago by Tao Liu

Snippets by tags

string (14) reflection (18) Design Patterns (18) Learning F# (15) fold (13) monad (18) Algorithms (21) math (28) Collections (12) lazy (17) SilverLight (21) Sequence (28) DSL (20) lists (12) computation builder (13) Seq (42) Kata (16) MailboxProcessor (19) web (15) list (37) WPF (15) recursion (23) parsing (20) tryfsharp (38) game (22) sequences (42) async (63) agent (16) F# (32) tutorial (15)
View all..

Snippets by authors

View all..

Database contains 1402 snippets out of which 1062 are public.