[Pkg-libvirt-commits] [libguestfs] 31/179: mllib: Add 'combine3' function.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 31 19:08:02 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 43e150c212c311aa9dbf535faa756b34bf7f580a
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Wed Oct 8 14:59:52 2014 +0100

    mllib: Add 'combine3' function.
---
 mllib/common_utils.ml  | 6 ++++++
 mllib/common_utils.mli | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index d3fec06..ba39b70 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -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"
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index 5bf4fba..71ccb4c 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -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]. *)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list