diff options
author | herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2001-03-12 14:27:46 +0000 |
---|---|---|
committer | herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2001-03-12 14:27:46 +0000 |
commit | 7b033ce4a3581db4421670f4d0d665349bb8c086 (patch) | |
tree | fd1783a1107615edcd8e3a6fdb4283141b2e2de1 /lib | |
parent | e2ef562eddb9af1e58a98c62d9a7eabede0b471d (diff) |
Ajout list_map3
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@1453 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.ml | 8 | ||||
-rw-r--r-- | lib/util.mli | 2 |
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 |