Snippets tagged Learning F#

  • Pascal's Triangle

    This code sample generates Pascal's triangle as jagged 2D list (list of lists).

    19 people like this

    Posted: 13 years ago by Dmitry Soshnikov

  • Scheme interpreter in F#

    A small Scheme interpreter using Higher Order Abstract Syntax (HOAS) encoding for terms. The essence of the technique is to use F# (meta-level) functions to encode Scheme (object-level) functions and other binding constructs, thus avoiding the need for representing variables, bindings, explicit substitution and dealing with shadowing.

    37 people like this

    Posted: 13 years ago by Anton Tayanovskyy

  • Finding matching pairs in two sequences

    Here's a function which takes a comparator function and two sequences, and returns tuples consisting of an item from each sequence, where the comparator function returns true for those two items. This is a small part of my wider project to generate guitar chord shapes. One of the requirements there is to take a list of 'wanted' notes for a chord, and a list of 'available' notes within a range of frets and to combine them into an actual set of frettings. That's what led to tryFindFirstPair and hence to findPairs.

    1 people like this

    Posted: 12 years ago by Kit Eason

  • Langton's ant

    Implementation of Langton's ant route.. Takes first 1000 steps and returns only black fields.

    2 people like this

    Posted: 12 years ago by stejcz

  • What word is most like the word "turtle"?

    A while ago I posted a snippet to calculate the 'Discrete Fréchet Distance' between two curves. If we treat a word as a 'curve' by giving each letter an index (with similar-sounding letters having closer indices) we can compare words by the Fréchet distance between them! An alternative to edit-distance...

    3 people like this

    Posted: 12 years ago by Kit Eason

  • Calculate the root-mean-square (RMS) of a dataset

    Calculate the root-mean-square of a dataset. Eg. given the voltages over time of an alternating current, calculate the RMS voltage.

    3 people like this

    Posted: 10 years ago by Kit Eason

  • Monad Bind 2 of 3

    After watching this clip (http://www.youtube.com/watch?v=ZhuHCtR3xq8) on Youtube featuring Brian Beckman I wanted to try to sketch Brian's main argument that Monads' main purpose is function composition. I will post my sketch to http://rodhern.wordpress.com/2014/02/ . These snippets are the companion examples to the blog post.

    1 people like this

    Posted: 10 years ago by Robert Nielsen

  • Text file line filter (script)

    A script suitable for FSI that copies a (UTF-8) text file throwing away uninteresting lines in the process.

    2 people like this

    Posted: 9 years ago by Robert Nielsen