Module Misc_stdlib.Array

Extensions to the Array module

val exists2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool

Same as Array.exists2 from the standard library.

val fold_left2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a array -> 'b array -> 'acc

fold_left2 f init [|a1; ...; an|] [|b1; ...; bn|] is f (... (f (f init a1 b1) a2 b2) ...) an bn.

  • raises Invalid_argument

    if the two arrays are determined to have different lengths.

val for_alli : (int -> 'a -> bool) -> 'a array -> bool

Same as Array.for_all from the standard library, but the function is applied with the index of the element as first argument, and the element itself as second argument.

val all_somes : 'a option array -> 'a array option
val equal : ('a -> 'a -> bool) -> 'a array -> 'a array -> bool

Compare two arrays for equality, using the supplied predicate for element equality

val compare : ('a -> 'a -> int) -> 'a array -> 'a array -> int

Compare two arrays, using the supplied predicate for element equality

val map_sharing : ('a -> 'a) -> 'a array -> 'a array

map_sharing f a is map f a. If for all elements of the array f e == e then map_sharing f a == a

val of_list_map : ('a -> 'b) -> 'a list -> 'b array