Recent snippets

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.

    119 people like this

    Posted: 7 years ago by Alex Muscar

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

    88 people like this

    Posted: 7 years ago by Neil Carrier

  • Project Euler #1

    This snippet is code that solves first Project Euler problem. It finds the sum of all the multiples of 3 or 5 below 1000. Please add other (more efficient, succinct or interesting) solutions to this snippet.

    72 people like this

    Posted: 7 years ago by Eugene Gavrin

  • Break sequence into n-element subsequences

    I'm working on parallel computations and I thought it would be useful to break work into chunks, especially when processing each element asynchronously is too expensive. The neat thing is that this function is general even though motivation for it is specific. Another neat thing is that this is true lazy sequence unlike what you'd get if you used Seq.groupBy. There are three versions for your enjoyment.

    70 people like this

    Posted: 7 years ago by Dmitri Pavlenkov

  • Asynchronous sequences

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

    107 people like this

    Posted: 7 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.

    359 people like this

    Posted: 7 years ago by Blake Coverett

Snippets by tags

math (32) parsing (22) collections (16) game (30) quotations (17) fparsec (14) string (18) f# (42) fold (19) array (18) kata (17) web (24) tutorial (17) learning f# (16) sequence (29) lazy (18) html (14) http (15) sequences (47) monad (20)

View all...

Database contains 2194 snippets out of which 1504 is public.