Skip to content

Instantly share code, notes, and snippets.

@alexwirz
Created August 15, 2014 16:57
Show Gist options
  • Save alexwirz/a23cae6d471e7ab1efa3 to your computer and use it in GitHub Desktop.
Save alexwirz/a23cae6d471e7ab1efa3 to your computer and use it in GitHub Desktop.
let has number list = List.exists (fun elem -> elem = number) list
let rec distinct list =
match list with
[] -> []
| x :: xs when has x xs -> distinct xs
| x :: xs -> x :: distinct xs
let l = [ 1; 2; 3; 1; 2; 1 ]
distinct l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment