| 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 =
(** {2 List processing} *)
-val list_uniq: 'a list -> 'a list (* uniq unix filter on lists *)
-val filter_map: ('a -> 'b option) -> 'a list -> 'b list (* filter + map *)
+val list_uniq: 'a list -> 'a list (** uniq unix filter on lists *)
+val filter_map: ('a -> 'b option) -> 'a list -> 'b list (** filter + map *)
+val list_concat: ?sep:'a list -> 'a list list -> 'a list (**String.concat-like*)
(** {2 Debugging & Profiling} *)