mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
pp: expose fill and and fill_map
This commit is contained in:
parent
58596a9bd5
commit
1ed81107df
2 changed files with 11 additions and 0 deletions
|
|
@ -358,6 +358,8 @@ let fill sep = function
|
||||||
in
|
in
|
||||||
{ view = Fill { sep; l }; wfl }
|
{ view = Fill { sep; l }; wfl }
|
||||||
|
|
||||||
|
let fill_map sep f l = fill sep (List.map f l)
|
||||||
|
|
||||||
let of_list ?(sep = nil) f l =
|
let of_list ?(sep = nil) f l =
|
||||||
let rec loop = function
|
let rec loop = function
|
||||||
| [] -> nil
|
| [] -> nil
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,12 @@ val newline : t
|
||||||
val nl : t
|
val nl : t
|
||||||
(** Alias for {!newline} *)
|
(** Alias for {!newline} *)
|
||||||
|
|
||||||
|
val fill : t -> t list -> t
|
||||||
|
(** [fill sep l] resembles [group (append_l ~sep l)], except it tries
|
||||||
|
to put as many items of [l] as possible on each line.
|
||||||
|
|
||||||
|
In terms of {!Format}, this is like the hov box. *)
|
||||||
|
|
||||||
(** {2 Output device} *)
|
(** {2 Output device} *)
|
||||||
|
|
||||||
(** Arbitrary output.
|
(** Arbitrary output.
|
||||||
|
|
@ -167,6 +173,9 @@ val append_sp : t list -> t
|
||||||
val append_nl : t list -> t
|
val append_nl : t list -> t
|
||||||
(** Same as {!append_l} with [sep=nl] *)
|
(** Same as {!append_l} with [sep=nl] *)
|
||||||
|
|
||||||
|
val fill_map : t -> ('a -> t) -> 'a list -> t
|
||||||
|
(** [fill_map sep f l] is [fill sep (List.map f l)] *)
|
||||||
|
|
||||||
val bool : bool -> t
|
val bool : bool -> t
|
||||||
val int : int -> t
|
val int : int -> t
|
||||||
val float : float -> t
|
val float : float -> t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue