F# Snippets

Recently added snippets

  • Fast Async Stream Copy

    This is a simple code implementation to copy Streams leveraging the Async workflow. After the first read, the write and read processes are done in parallel. I also used an Array of Array as buffer to avoid false sharing memory. An other improvment option could be to increase the buffer size if the copy is done in same machine.

    Posted: yesterday by Riccardo Terrell

  • A type-level SAT solver in F#

    A type-level SAT solver in F#, inspired by https://gist.github.com/wouter-swierstra/0b6062c9660e751cd535

    Posted: 2 days ago by Nick Palladinos

  • Extending units of measure to arbitrary types

    Continuing from https://twitter.com/JKPappas/status/558339587719045120, here's an approach on extending units of measure to arbitrary types.

    Posted: 3 days ago by Eirik Tsarpalis

  • Pluck and TryPluck

    Functions to select the first element in an array that passes some predicate, and separately all the other array elements. (I'm not sure if this type of operation has a standard name. Please tweet me if you know!)

    Posted: 3 days ago by Kit Eason

  • Recursively find all files from a sequence of directories

    A function that will take a sequence of directory names and recursively find and return a sequence of all file names within.

    Posted: 5 days ago by Andreas Ågren

  • 3D Image Effect

    You can create a 3D effect by taking each pixel from the source image (removing the red) and the pixel twenty places to its left (removing the blue and green) and blending the two together

    Posted: 9 days ago by Riccardo Terrell

Popular snippets

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

  • Minimal XML DSL

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

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

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

  • WPF / SilverLight Converter II

    version 1 is http://fssnip.net/62. This new version support convert from any existing function to a converter function by using composition and pipeline. The convert function is to make the function signature agree to the IValueConverter interface. You can add new functions in the FunctionLibrary module and reuse the class definition to reduce the coding effort. The first sample is to show how to make the converter pipeline work, the second one is a debugger converter used to debug the data binding problem.

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

  • Load XAML

    This example shows how to load a Xaml file allowing to use WPF from F#. It also shows how to access WPF objects and register event handlers.

    94 people like this
    Posted: 4 years ago by Antonio Cisternino

  • Get Stock Quote Data and Historical Stock Prices from Yahoo Finance

    Get Stock Quote Data and Historical Stock Prices from Yahoo Finance.

    218 people like this
    Posted: 4 years ago by Tuomas Hietanen

Snippets by tags

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

Snippets by authors

View all..

Database contains 1538 snippets out of which 1147 are public.