F# Snippets

Recently added snippets

  • Fun3D Castle

    3D castle sample from the Fun3D project, now written using WebGL and running in a web browser...

    Posted: 2 days ago by Tomas Petricek

  • Hello world

    A very simple function to print hello world, which is completely useless. Just testin the F# Snippets API...

    Posted: 2 days ago by Tomas Petricek

  • Extract info from F# Compiler Service exceptions

    When you get an exception from the F# Compiler Service, it usually does not print any useful information. But you can look at the private fields of the exception and get some more useful things out of it...

    Posted: 4 days ago by Tomas Petricek

  • Analyzing Government Data

    F# Snippet based on Dave Crook's article "Intro to C# and Analyzing Government Data"; http://blogs.msdn.com/b/dave_crooks_dev_blog/archive/2015/04/20/intro-to-c-and-analyzing-government-data.aspx

    Posted: 6 days ago by Phillip Trelford

  • Automatically compile LaTeX documents

    A simple script that automatically recompiles LaTeX documents when they are saved. Works nicely when editing papers in Atom and using SumatraPDF for preview (Sumatra automatically reloads PDF documents). Does not report errors or anything clever (!)

    Posted: 15 days ago by Tomas Petricek

  • Memoize Async Function

    Cache a function's asynchronously-computed result for each argument to reduce expensive and repetitive computation of an asynchronous operation. Uses a concurrent dictionary for backing storage, and at-least-once invocation semantics per key.

    Posted: 20 days ago by Jonathan Leaver

Popular snippets

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

    96 people like this
    Posted: 4 years ago by Blake Coverett

  • Adapter pattern

    Invoke the methods from incompatible types

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

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

    81 people like this
    Posted: 4 years ago by Neil Carrier

  • Pipeline list processing

    An example showing how to process list in a pipeline. We first use List.filter to return only even numbers and then use List.map to format them as strings.

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

  • Minimal XML DSL

    This snippet provides a very small internal DSL for creating and querying XML using the underlying XLinq classes.

    336 people like this
    Posted: 4 years ago by Blake Coverett

  • A beautiful fixed-point finding function

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

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

Snippets by tags

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

Snippets by authors

View all..

Database contains 1619 snippets out of which 1188 are public.