Skip to content

Instantly share code, notes, and snippets.

type FizzBuzz =
| Fizzy of int
| Buzzy of int
| FizzBuzzy of int
| NormalNumber of int
let fizzBuzz x =
match x with
| x when (x % 15) = 0 -> FizzBuzzy(x)
| x when (x % 5) = 0 -> Buzzy(x)
@doorhammer
doorhammer / stringSimilarity.js
Created April 3, 2014 16:32
Algorithm using the Sørensen–Dice coefficient to compare the similarity of two strings
var sSimilarity = function(sa1, sa2){
// Compare two strings to see how similar they are.
// Answer is returned as a value from 0 - 1
// 1 indicates a perfect similarity (100%) while 0 indicates no similarity (0%)
// Algorithm is set up to closely mimic the mathematical formula from
// the article describing the algorithm, for clarity.
// Algorithm source site: http://www.catalysoft.com/articles/StrikeAMatch.html
// (Most specifically the slightly cryptic variable names were written as such
// to mirror the mathematical implementation on the source site)
//