]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/extlib/hExtlib.ml
added filter_map
[helm.git] / helm / ocaml / extlib / hExtlib.ml
index 06ac37b13c19197dfa5245f4afd16af5dec27acc..d3ae69402313132ce3457193296b60ca9b32e5d4 100644 (file)
@@ -96,6 +96,14 @@ let rec list_uniq = function
   | h1::h2::tl when h1 = h2 -> list_uniq (h2 :: tl) 
   | h1::tl (* when h1 <> h2 *) -> h1 :: list_uniq tl
 
+let rec filter_map f =
+  function
+  | [] -> []
+  | hd :: tl ->
+      (match f hd with
+      | None -> filter_map f tl
+      | Some v -> v :: filter_map f tl)
+
 (** {2 File predicates} *)
 
 let is_dir fname =