Commit c7e3e0bf authored by Guillaume Melquiond's avatar Guillaume Melquiond

Add Pp.print_list_pre for printing list using a prefix rather than an infix separator.

parent 2f2c7147
......@@ -23,10 +23,14 @@ let print_option_or_default default f fmt = function
| None -> fprintf fmt "%s" default
| Some x -> f fmt x
let rec print_list sep print fmt = function
let rec print_list_pre sep print fmt = function
| [] -> ()
| x :: r -> sep fmt (); print fmt x; print_list_pre sep print fmt r
let print_list sep print fmt = function
| [] -> ()
| [x] -> print fmt x
| x :: r -> print fmt x; sep fmt (); print_list sep print fmt r
| x :: r -> print fmt x; print_list_pre sep print fmt r
let print_list_or_default default sep print fmt = function
| [] -> fprintf fmt "%s" default
......
......@@ -16,6 +16,9 @@ open Format
val print_option : (formatter -> 'a -> unit) -> formatter -> 'a option -> unit
val print_option_or_default :
string -> (formatter -> 'a -> unit) -> formatter -> 'a option -> unit
val print_list_pre :
(formatter -> unit -> unit) ->
(formatter -> 'a -> unit) -> formatter -> 'a list -> unit
val print_list :
(formatter -> unit -> unit) ->
(formatter -> 'a -> unit) -> formatter -> 'a list -> unit
......
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