]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/extlib/hExtlib.ml
added list_concat
[helm.git] / helm / ocaml / extlib / hExtlib.ml
index 31cf86a75d4007d6a570fbee91418cd22330f8aa..ceb9c8d8bc1ca21fd3a361db1d951300136a34de 100644 (file)
@@ -104,6 +104,15 @@ let rec filter_map f =
       | None -> filter_map f tl
       | Some v -> v :: filter_map f tl)
 
+let list_concat ?(sep = []) =
+  let rec aux acc =
+    function
+    | [] -> []
+    | [ last ] -> List.flatten (List.rev (last :: acc))
+    | hd :: tl -> aux ([sep; hd] @ acc) tl
+  in
+  aux []
+
 (** {2 File predicates} *)
 
 let is_dir fname =