Project

General

Profile

Revision 217837e2 src/utils/utils.ml

View differences:

src/utils/utils.ml
253 253
let pp_newline_if_non_empty l =
254 254
  (fun fmt -> match l with [] -> () | _ -> Format.fprintf fmt "@,")
255 255

  
256
let rec fprintf_list ~sep:sep f fmt = function
256
let fprintf_list ?(eol:('a, formatter, unit) Pervasives.format = "") ~sep:sep f fmt l =
257
  let rec aux fmt = function
257 258
  | []   -> ()
258 259
  | [e]  -> f fmt e
259
  | x::r -> Format.fprintf fmt "%a%(%)%a" f x sep (fprintf_list ~sep f) r
260

  
260
  | x::r -> Format.fprintf fmt "%a%(%)%a" f x sep aux r
261
  in
262
  match l with
263
  | [] -> ()
264
  | _ -> (
265
    aux fmt l;
266
    Format.fprintf fmt "%(%)" eol
267
  )                 
268
   
261 269
let pp_list l pp_fun beg_str end_str sep_str =
262 270
  if (beg_str="\n") then
263 271
    print_newline ()

Also available in: Unified diff