Skip to content

Instantly share code, notes, and snippets.

@rizo
Forked from cqfd/uniques.ml
Last active August 29, 2015 14:19
Show Gist options
  • Save rizo/d3bbecdeee3bc12a9a5d to your computer and use it in GitHub Desktop.
Save rizo/d3bbecdeee3bc12a9a5d to your computer and use it in GitHub Desktop.
let rec elem x xs =
match xs with
| [] -> false
| y :: ys -> x = y || elem x ys
let rec uniques l =
let rec helper l acc =
match l with
| [] -> acc
| x :: xs ->
if elem x acc then
helper xs acc
else
helper xs (x :: acc)
in List.rev (helper l [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment