Snippets created by Rick Minerich

  • 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: 10 years ago by Rick Minerich

  • Jaro-Winkler in F#

    Jaro-Winkler is a fast and effective name matching algorithm. For more info see "A Comparison of String Distance Metrics for Name-Matching Tasks" http://www.isi.edu/info-agents/workshops/ijcai03/papers/Cohen-p.pdf or the Wikipedia article http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance

    29 people like this

    Posted: 10 years ago by Rick Minerich

  • Partition a sequence into groups linearly by predicate

    Partitions a sequence into groups linearly by predicate. I use this for breaking up my lazy record parsing with sequences into entity-sized chunks which are then easily digestible. Note: Edited back from the previous edit as these were heavily profiled and yield! tends to be slow. Edit #2: Now correctly using "use" instead of "let" for sequence.GetEnumerator () (Thanks Vladimir Matveev)

    1 people like this

    Posted: 10 years ago by Rick Minerich

  • memoizeBy

    Sometimes you might wish to memoize a function whose input doesn't have the equality and comparison constraints, or maybe the comparison of your given type is just too slow for what you need. To fix this, you simply provide a function which converts the input into something more fitting as an extra parameter.

    7 people like this

    Posted: 9 years ago by Rick Minerich

  • A Small DSL for Building Graphs

    A small DSL for graph building by combining paths. It's just a set of edges under the hood, so no need to worry about duplication causing problems. This is part of a larger project I'm calling edgy.

    9 people like this

    Posted: 8 years ago by Rick Minerich

  • Using Expressions to Clone F# Values

    How to generate functions for copying F# record-array-union trees with Expr.

    1 people like this

    Posted: 6 years ago by Rick Minerich

  • Type Inference for ML/Haskell

    This is just the ML code from http://jozefg.bitbucket.org/posts/2015-02-28-type-inference.html ported to F#.

    3 people like this

    Posted: 6 years ago by Rick Minerich

  • Very Fast Permutations

    I spent a lot of time this week profiling different permutation functions from various places on the internet. The following was by far the fastest:

    5 people like this

    Posted: 1 year ago by Rick Minerich