aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/util.ml8
-rw-r--r--lib/util.mli2
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml
index 9aee36e20..29273b169 100644
--- a/lib/util.ml
+++ b/lib/util.ml
@@ -129,6 +129,14 @@ let list_map2_i f i l1 l2 =
in
map_i i (l1,l2)
+let list_map3 f l1 l2 l3 =
+ let rec map = function
+ | ([], [], []) -> []
+ | ((h1::t1), (h2::t2), (h3::t3)) -> (f h1 h2 h3) :: (map (t1,t2,t3))
+ | (_, _, _) -> invalid_arg "map3"
+ in
+ map (l1,l2,l3)
+
let list_index x =
let rec index_x n = function
| y::l -> if x = y then n else index_x (succ n) l
diff --git a/lib/util.mli b/lib/util.mli
index 1a70a62f9..274d97af4 100644
--- a/lib/util.mli
+++ b/lib/util.mli
@@ -60,6 +60,8 @@ val list_distinct : 'a list -> bool
val list_map_i : (int -> 'a -> 'b) -> int -> 'a list -> 'b list
val list_map2_i :
(int -> 'a -> 'b -> 'c) -> int -> 'a list -> 'b list -> 'c list
+val list_map3 :
+ ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd list
val list_index : 'a -> 'a list -> int
val list_iter_i : (int -> 'a -> unit) -> 'a list -> unit
val list_fold_left_i : (int -> 'a -> 'b -> 'a) -> int -> 'a -> 'b list -> 'a