Created
November 21, 2012 13:54
-
-
Save pocketberserker/4124957 to your computer and use it in GitHub Desktop.
FSharpx.BKTree.(List | ByteString).distance short examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Reference: http://en.wikipedia.org/wiki/Levenshtein_distance#Example | |
kitten → sitten (substitution of 's' for 'k') | |
sitten → sittin (substitution of 'i' for 'e') | |
sittin → sitting (insertion of 'g' at the end). | |
*) | |
open FSharpx.DataStructures | |
open FSharpx.ByteString | |
// List | |
let kitten = "kitten".ToCharArray() |> Array.toList | |
let sitting = "sitting".ToCharArray() |> Array.toList | |
assert(BKTree.List.distance kitten sitting = 3) | |
// ByteString | |
let kitten = "kitten" |> ByteString.ofString | |
let sitting = "sitting" |> ByteString.ofString | |
assert(BKTree.ByteString.distance kitten sitting = 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment