Commit 32eed1ae authored by Pietro Abate's avatar Pietro Abate

Add common printing functions

parent 0aab8a5e
let string_of_formatter pp t =
Format.fprintf Format.str_formatter "%a" pp t;
Format.flush_str_formatter ()
let pp_list ?(delim=("[","]")) ?(sep=",") f ppf l =
let rec aux ppf = function
|[] -> Format.fprintf ppf ""
|[h] -> Format.fprintf ppf "%a" f h
|h::t -> Format.fprintf ppf "%a%s%a" f h sep aux t
in
match l with
|[] -> Format.fprintf ppf "%s%s" (fst delim) (snd delim)
|_ -> Format.fprintf ppf "%s%a%s" (fst delim) aux l (snd delim)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment