Commit 366249e5 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Add [Misc.array_for_all2].

parent 72849b3a
......@@ -405,3 +405,14 @@ let array_for_all p a =
else if p (Array.unsafe_get a i) then loop (succ i)
else false in
loop 0
(* Similarly, we copy [Array.for_all2], which appeared in 4.11. *)
let array_for_all2 p l1 l2 =
let n1 = Array.length l1
and n2 = Array.length l2 in
if n1 <> n2 then invalid_arg "Array.for_all2"
else let rec loop i =
if i = n1 then true
else if p (Array.unsafe_get l1 i) (Array.unsafe_get l2 i) then loop (succ i)
else false in
loop 0
......@@ -189,3 +189,4 @@ val nth: int -> string
(* [Array.for_all] *)
val array_for_all : ('a -> bool) -> 'a array -> bool
val array_for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment