Recent snippets

  • Disposable Scopes provided by scope {...} computational workflow.

    This snippet provides a builder for scope {...} computational workflow that returns a Scope object implementing System.IDisposable interface. All "use" bindings inside scope {...} workflow are kept from being disposed immediately when computation leaves scope. Instead, they are disposed only when resulting Scope object is disposed. This makes possible to access disposable outside the scope while it remains usable. This can be achieved by via return statement of workflow that can return, for example, a closure that encapsulates disposable. scope {...} return value is available through Value property of Scope object. Scopes may be nested through let! binding that means that nested scope will be disposed when the resulting scope is disposed.

    2 people like this

    Posted: 1 month ago by Crazy Monk

  • StringBuilderCache.fs

    F# Impletementation of StringBuilderCache

    1 people like this

    Posted: 1 month ago by Pim

  • Rotate or shift lists

    This rotates or shifts a list. Unlike http://www.fssnip.net/qY/title/Rotate-List, which runs exponentially, this runs at O(n). In case of overflow (i.e., shift index is larger than the size of the list) will run at most once more with the modulo. This is done to prevent using `List.length` prior to entering the function, as that would lead to a perf punishment of an extra O(n) on each invocation. For large lists, `shift largeList 1` would then get a big performance hit.

    1 people like this

    Posted: 1 month ago by Abel Braaksma

Popular snippets

  • Dynamic operator using Reflection

    Demonstrates how to implement the dynamic operator (?) using .NET Reflection. The implementation supports calling constructors, propreties and methods using simple overload resolution (based on parameter count). It handles instance as well as static members.

    67 people like this

    Posted: 11 years ago by Tomas Petricek

  • Units of Measure

    Show's how to define units of measure to add stronger typing to your numerical functions.

    75 people like this

    Posted: 11 years ago by Robert Pickering

  • Partition a sequence until a predicate is satiated

    This function is given a partition predicate and a sequence. Until the predicate returns false, a list will be filled with elements. When it is, both the list and the remainder of the sequence will be returned. Note that this example preserves the laziness of the unchecked sequence elements.

    68 people like this

    Posted: 11 years ago by Rick Minerich

Snippets by tags

mailboxprocessor (27) learning f# (16) staging (18) string (27) regex (16) sequence (32) f# (44) list (56) tutorial (17) math (35) wpf (20) lists (14) kata (17) recursion (33) tryfsharp (48) fparsec (15) design patterns (18) lazy (20) agent (20) game (32)

View all...

Database contains 3035 snippets out of which 1696 is public.