X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=utils.ml;h=43119ee2d8c49664dbc51f0da2aa4d2582f6bee4;hb=9b311682ee639fc3399056b7b93ba9bd0140a639;hp=25fc7400d3587443ff64d6b21dd1c12fc9ee6aba;hpb=50790d6953d8bc68fd373f1c09949f7bff385050;p=goaljobs-goals.git diff --git a/utils.ml b/utils.ml index 25fc740..43119ee 100644 --- a/utils.ml +++ b/utils.ml @@ -16,3 +16,10 @@ let sort_uniq ?(cmp = Pervasives.compare) xs = let xs = List.sort cmp xs in let xs = uniq ~cmp xs in xs + +let rec filter_map f = function + | [] -> [] + | x :: xs -> + match f x with + | Some y -> y :: filter_map f xs + | None -> filter_map f xs