module Array: sig .. end
Standard Ocaml Array module with extended functionality.
Extended functionality
val sum : int array -> int
sum a returns the sum of the elements of the int array a.
val sumf : float array -> float
sum a returns the sum of the elements of the float array a.
val sum_map : ('a -> int) -> 'a array -> int
sum_map f a applies the function f on each element of the
int array a and then returns the sum of the results.
val sumf_map : ('a -> float) -> 'a array -> float
sum_map f a applies the function f on each element of the
float array a and then returns the sum of the results.
val find : ('a -> bool) -> 'a array -> 'a
find p a returns the first element of the array a
that satisfies the predicate p.
Raises Not_found if there is no value that satisfies p in the
list l.
val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
map2 f [|a1; ...; an|] [|b1; ...; bn|] is
[|f a1 b1; ...; f an bn|].
val iter2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> unit
iter2 f [|a1; ...; an|] [|b1; ...; bn|] calls in turn
f a1 b1; ...; f an bn.
val rev_iter : ('a -> 'b) -> 'a array -> unit
rev_iter f a is the same as iter f a, but iterates from
right to left.
exception Found
val exists : ('a -> bool) -> 'a array -> bool
exists p [|a1; ...; an|] checks if at least one element of
the array satisfies the predicate p.
Raises Found when the predicate is satisfied.
val for_all : ('a -> bool) -> 'a array -> bool
for_all p [|a1; ...; an|] checks if all elements of the
array satisfy the predicate p.
val count : ('a -> bool) -> 'a array -> int
count f a applies the boolean function f on each element
of the array a and returns the number of times that f returns
true.
val min : 'a array -> 'a
min a returns the mininum value of the array a.
val max : 'a array -> 'a
max a returns the maximum value of the array a.
val argmin : 'a array -> int
argmin a returns the index of the smallest value in the
array a.
val argmax : 'a array -> int
argmax a returns the index of the largest value in the array
a.
val rev_inplace : 'a array -> unit
rev_inplace a reverses the array a in place.
val transpose : 'a array array -> 'a array array
transpose m transposes the matrix m represented as an
array of arrays.
val flattenl : 'a list array -> 'a array
The elements of the argument are all concatenated together (in
the same order) to give the result. Not tail-recursive.
val flatten : 'a array array -> 'a array
Flatten a matrix (array of array) into an array.
val rev_flatten : 'a array -> int -> int -> 'a array array
rev_flatten a dimx dimy creates a matrix given an array and
the dimension of the matrix.
val filter : ('a -> bool) -> 'a array -> 'a array
filter p a returns all the elements of the array a that
satisfy the predicate p.
val partition : ('a -> bool) -> 'a array -> 'a array * 'a array
partition p a returns a pair of arrays (a1, a2), where
a1 is the array of all the elements of a that satisfy the
predicate p, and a2 is the array of all the elements of a
that do not satisfy p. The order of the elements in the input
array is preserved.
val rev : 'a array -> 'a array
Returns a new array which is the reverse of the argument.
val trans : 'a array array -> 'a array array
Deprecated.Use transpose instead.
val take : 'a array -> int array -> 'a array
take a ai removes the indices ai from the array a.
val takeCol : 'a array array -> int array -> 'a array array
takeCol m cols removes the columns cols from the matrix
m. The matrix m is represented using an array of arrays.
val takeRow : 'a array array -> int array -> 'a array array
takeRow m rows removes the rows rows from the matrix m.
The matrix m is represented using an array of arrays.
val range : int -> int array
range n creates an array with values from 0 to n-1.
val augment : 'a array -> ('a * int) array
Creates a new array such that if the ith entry of the given
array has value v, then the ith entry of the new array
contains the pair (v,i).
Functions from the original Array module
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val init : int -> (int -> 'a) -> 'a array
val make_matrix : int -> int -> 'a -> 'a array array
val create_matrix : int -> int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> int -> int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> int -> int -> 'a -> unit
val blit : 'a array -> int -> 'a array -> int -> int -> unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : ('a -> unit) -> 'a array -> unit
val map : ('a -> 'b) -> 'a array -> 'b array
val iteri : (int -> 'a -> unit) -> 'a array -> unit
val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
val sort : ('a -> 'a -> int) -> 'a array -> unit
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit