diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/util.ml | 7 | ||||
| -rw-r--r-- | lib/util.mli | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml index af5f2e33c4..42cdc2bf2c 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -800,6 +800,13 @@ let list_cartesians op init ll = let list_combinations l = list_cartesians (fun x l -> x::l) [] l +let rec list_combine3 x y z = + match x, y, z with + | [], [], [] -> [] + | (x :: xs), (y :: ys), (z :: zs) -> + (x, y, z) :: list_combine3 xs ys zs + | _, _, _ -> raise (Invalid_argument "list_combine3") + (* Keep only those products that do not return None *) let rec list_cartesian_filter op l1 l2 = diff --git a/lib/util.mli b/lib/util.mli index 98d2b6cf9d..43dd439131 100644 --- a/lib/util.mli +++ b/lib/util.mli @@ -213,6 +213,7 @@ val list_cartesians : ('a -> 'b -> 'b) -> 'b -> 'a list list -> 'b list (** list_combinations [[a;b];[c;d]] returns [[a;c];[a;d];[b;c];[b;d]] *) val list_combinations : 'a list list -> 'a list list +val list_combine3 : 'a list -> 'b list -> 'c list -> ('a * 'b * 'c) list (** Keep only those products that do not return None *) val list_cartesian_filter : |
