mllib: Add 'combine3' function.

This commit is contained in:
Richard W.M. Jones
2014-10-08 14:59:52 +01:00
parent 8adc32cae8
commit 43e150c212
2 changed files with 9 additions and 0 deletions

View File

@@ -199,6 +199,12 @@ let rec mapi i f =
r :: mapi (i + 1) f l
let mapi f l = mapi 0 f l
let rec combine3 xs ys zs =
match xs, ys, zs with
| [], [], [] -> []
| x::xs, y::ys, z::zs -> (x, y, z) :: combine3 xs ys zs
| _ -> invalid_arg "combine3"
(* ANSI terminal colours. *)
let ansi_green ?(chan = stdout) () =
if TTY.isatty_stdout () then output_string chan "\x1b[0;32m"

View File

@@ -53,6 +53,9 @@ val iteri : (int -> 'a -> 'b) -> 'a list -> unit
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
(** Various higher-order functions. *)
val combine3 : 'a list -> 'b list -> 'c list -> ('a * 'b * 'c) list
(** Like {!List.combine} but for triples. All lists must be the same length. *)
val make_message_function : quiet:bool -> ('a, unit, string, unit) format4 -> 'a
(** Timestamped progress messages. Used for ordinary messages when
not [--quiet]. *)