let dedup ?(compare=Pervasives.compare) list = let equal x x' = compare x x' = 0 in let sorted = sort ~cmp:compare list in remove_consecutive_duplicates ~equal sorted