]> matita.cs.unibo.it Git - helm.git/blobdiff - components/extlib/hExtlib.ml
Add_moo_content modified to avoid repetitions of index command during inclusion.
[helm.git] / components / extlib / hExtlib.ml
index c0364315a62c018923f2c9e76873a35087c15fd2..073c5695959480e657070af45a68ec3029132ef6 100644 (file)
@@ -153,6 +153,28 @@ let rec filter_map f =
       | None -> filter_map f tl
       | Some v -> v :: filter_map f tl)
 
+let list_rev_map_filter f l =
+   let rec aux a = function
+      | []       -> a
+      | hd :: tl -> 
+         begin match f hd with
+           | None   -> aux a tl
+           | Some b -> aux (b :: a) tl 
+         end
+   in 
+   aux [] l
+
+let list_rev_map_filter_fold f v l =
+   let rec aux v a = function
+      | []       -> v, a
+      | hd :: tl -> 
+         begin match f v hd with
+           | v, None   -> aux v a tl
+           | v, Some b -> aux v (b :: a) tl 
+         end
+   in 
+   aux v [] l
+
 let list_concat ?(sep = []) =
   let rec aux acc =
     function