X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fextlib%2FhExtlib.ml;h=8451eb6b86c69eb435adf561a7290497cc353ff3;hb=8bc5bc0e8375a85736f6a5df317d129d5efa8de4;hp=5f2c7f78caab9eef51dc733ebe59d4addfee1194;hpb=d3548c16f481b14ce94e64c790bc767c59590050;p=helm.git diff --git a/helm/software/components/extlib/hExtlib.ml b/helm/software/components/extlib/hExtlib.ml index 5f2c7f78c..8451eb6b8 100644 --- a/helm/software/components/extlib/hExtlib.ml +++ b/helm/software/components/extlib/hExtlib.ml @@ -217,6 +217,18 @@ let rec filter_map f = | None -> filter_map f tl | Some v -> v :: filter_map f tl) +let filter_map_acc f acc l = + let acc, res = + List.fold_left + (fun (acc, res) t -> + match f acc t with + | None -> acc, res + | Some (acc, x) -> acc, x::res) + (acc,[]) l + in + acc, List.rev res +;; + let list_rev_map_filter f l = let rec aux a = function | [] -> a @@ -248,6 +260,15 @@ let list_concat ?(sep = []) = in aux [] +let list_iter_sep ~sep f = + let rec aux = + function + | [] -> () + | [ last ] -> f last + | hd :: tl -> f hd; sep (); aux tl + in + aux + let rec list_findopt f l = let rec aux k = function | [] -> None