F# Snippets

Recently added snippets

  • Mass shootings in the US

    Based on the article "We’re now averaging more than one mass shooting per day in 2015", this calculates when is the best time to go to US to avoid being shot.

    Posted: 5 days ago by Tomas Petricek

  • GrahamScan.fsx

    Function to perform the Graham scan algorithm which looks for the set of points forming the convex hull of the input points

    Posted: 11 days ago by albertp007

  • ReadWavFile.fsx

    Function to read a wav file

    Posted: 11 days ago by albertp007

  • Rx Web Server Demo

    Barebone Reactive Extensions web server demo.

    Posted: 14 days ago by Giacomo Stelluti Scala

  • Flappy bird with sequence expressions

    This is a somewhat sensible solution to the flappy bird dojo by Phil Trelford. It uses sequence expressions eliminate some mutation of the flappy bird. To play this sample on Windows simply copy the code from the raw view and execute in F# interactive, for cross platform implementations check out: http://trelford.com/prognet15.zip

    Posted: 18 days ago by Tomas Petricek

  • Flappy bird with the flappy monad

    This is a crazy solution to the flappy bird dojo by Phil Trelford. It defines a custom computation builder to eliminate all mutation of the flappy bird. The script uses WPF and is playable on Windows in F# interactive, just copy the raw version, and for cross-platform implementations download: http://trelford.com/prognet15.zip

    Posted: 18 days ago by Tomas Petricek

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.

    87 people like this
    Posted: 4 years ago by Wolfgang Meyer

  • A beautiful fixed-point finding function

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

    280 people like this
    Posted: 4 years ago by Nick Palladinos

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

    167 people like this
    Posted: 4 years ago by Tomas Petricek

  • Asynchronous sequences

    An asynchronous sequence is similar to the seq<T> type, but the elements of the sequence are generated asynchronously without blocking the caller as in Async<T>. This snippet declares asynchronous sequence and uses it to compare two files in 1k blocks.

    99 people like this
    Posted: 4 years ago by Tomas Petricek

  • Adapter pattern

    Invoke the methods from incompatible types

    94 people like this
    Posted: 4 years ago by Tao Liu

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

    113 people like this
    Posted: 4 years ago by Alex Muscar

Snippets by tags

reflection (18) quotations (14) monad (19) MailboxProcessor (24) lazy (17) computation builder (13) Seq (44) WPF (16) sequences (44) tutorial (15) agent (19) recursion (24) Kata (16) list (46) game (29) string (16) fold (16) tryfsharp (46) Learning F# (15) Sequence (28) math (29) parsing (22) Algorithms (23) async (84) web (19) Design Patterns (18) DSL (22) f# (40) Collections (16) SilverLight (21)
View all..

Snippets by authors

View all..

Database contains 1712 snippets out of which 1260 are public.