Commits

camlspotter  committed 0150d8d

Xformat.list_sep_strs

  • Participants
  • Parent commits 77112ad

Comments (0)

Files changed (2)

File lib/xformat.ml

         sep
         (list sep f) xs
 
-let rec list_sep_str sep f ppf = function
+let rec list_sep_strs sep1 sep2 f ppf = function
   | [] -> ()
   | [x] -> f ppf x
   | x::xs ->
-      fprintf ppf "%a%s@,%a"
+      fprintf ppf "%a%s@,%s%a"
         f x
-        sep
-        (list_sep_str sep f) xs
+        sep1
+        sep2
+        (list_sep_strs sep1 sep2 f) xs
+
+let rec list_sep_str sep = list_sep_strs sep ""
 
 let option f ppf = function
   | None -> Format.fprintf ppf "None"

File lib/xformat.mli

 val stderr : t
 
 val list : (t -> unit) -> (t -> 'a -> unit) -> t -> 'a list -> unit
+val list_sep_strs : string -> string -> (t -> 'a -> unit) -> t -> 'a list -> unit
+  (** [list_sep_strs sep1 sep2 elem_formatter ppf elems] formats list of elem [elems] 
+      by the formatter for elem [elem_formatter], inserting [sep1], "@,", [sep2]
+      between elements.
+  *)
 val list_sep_str : string -> (t -> 'a -> unit) -> t -> 'a list -> unit
-  (** separator by string, then @, is inserted *)
+  (** Weak version of [list_sep_strs]. A version of [sep2 = ""] of [list_sep_strs].
+  *)
 
 val option : (t -> 'a -> unit) -> t -> 'a option -> unit
 val lazy_ : (t -> 'a -> unit) -> t -> 'a Lazy.t -> unit