use standard List.sort_uniq

This commit is contained in:
Simon Cruanes 2018-03-13 00:34:49 -05:00
parent 09d5b146f2
commit 7a22286ca1

View file

@ -580,13 +580,7 @@ let sorted_merge ~cmp l1 l2 =
List.length (sorted_merge ~cmp:CCInt.compare l1 l2) = List.length l1 + List.length l2) List.length (sorted_merge ~cmp:CCInt.compare l1 l2) = List.length l1 + List.length l2)
*) *)
let sort_uniq (type elt) ~cmp l = let sort_uniq (type elt) ~cmp l = List.sort_uniq cmp l
let module S = Set.Make(struct
type t = elt
let compare = cmp
end) in
let set = fold_right S.add l S.empty in
S.elements set
(*$T (*$T
sort_uniq ~cmp:CCInt.compare [1;2;5;3;6;1;4;2;3] = [1;2;3;4;5;6] sort_uniq ~cmp:CCInt.compare [1;2;5;3;6;1;4;2;3] = [1;2;3;4;5;6]