X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=components%2Fextlib%2FhExtlib.ml;h=073c5695959480e657070af45a68ec3029132ef6;hb=86458c2afc0d02aad6dc22267793b7538dc475d0;hp=c0364315a62c018923f2c9e76873a35087c15fd2;hpb=2499f5fdcf4dbfecc6f4fafe925b24ae76f14be8;p=helm.git diff --git a/components/extlib/hExtlib.ml b/components/extlib/hExtlib.ml index c0364315a..073c56959 100644 --- a/components/extlib/hExtlib.ml +++ b/components/extlib/hExtlib.ml @@ -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