Make F22 and F23 follow 1.30
[goaljobs-goals.git] / utils.ml
1 open Printf
2
3 open Goaljobs
4 open Config
5
6 (* From supermin *)
7 let rec uniq ?(cmp = Pervasives.compare) = function
8   | [] -> []
9   | [x] -> [x]
10   | x :: y :: xs when cmp x y = 0 ->
11       uniq ~cmp (x :: xs)
12   | x :: y :: xs ->
13       x :: uniq ~cmp (y :: xs)
14
15 let sort_uniq ?(cmp = Pervasives.compare) xs =
16   let xs = List.sort cmp xs in
17   let xs = uniq ~cmp xs in
18   xs
19
20 let rec filter_map f = function
21   | [] -> []
22   | x :: xs ->
23     match f x with
24     | Some y -> y :: filter_map f xs
25     | None -> filter_map f xs