1
2
3
4
5
6
7
let uniq xs =
  let rec uniq' acc = function
  | [] -> acc
  | y::ys when (List.mem y acc) -> uniq' acc ys
  | y::ys -> uniq' (y::acc) ys
  in
  List.rev (uniq' [] xs)