module Array: Arraytype'at ='a array
include Container.S1
val max_length : intmax_length/2 on 32-bit machines and max_length on 64-bit machines.val get : 'a t -> int -> 'aArray.get a n returns the element number n of array a.
The first element has number 0.
The last element has number Array.length a - 1.
You can also write a.(n) instead of Array.get a n.
Raise Invalid_argument "index out of bounds"
if n is outside the range 0 to (Array.length a - 1).
val set : 'a t -> int -> 'a -> unitArray.set a n x modifies array a in place, replacing
element number n with x.
You can also write a.(n) <- x instead of Array.set a n x.
Raise Invalid_argument "index out of bounds"
if n is outside the range 0 to Array.length a - 1.
val unsafe_get : 'a t -> int -> 'aget. Can cause arbitrary behavior when used to for an
out-of-bounds array accessval unsafe_set : 'a t -> int -> 'a -> unitset. Can cause arbitrary behavior when used to for an
out-of-bounds array accessval create : len:int -> 'a -> 'a tcreate ~len x creates an array of length len with the value x populated in each
elementval init : int -> f:(int -> 'a) -> 'a tinit n ~f creates an array of length n where the ith element is initialized with
f i (starting at zero)val make_matrix : dimx:int -> dimy:int -> 'a -> 'a t tArray.make_matrix dimx dimy e returns a two-dimensional array
(an array of arrays) with first dimension dimx and
second dimension dimy. All the elements of this new matrix
are initially physically equal to e.
The element (x,y) of a matrix m is accessed
with the notation m.(x).(y).
Raise Invalid_argument if dimx or dimy is negative or
greater than Sys.max_array_length.
If the value of e is a floating-point number, then the maximum
size is only Sys.max_array_length / 2.
val append : 'a t -> 'a t -> 'a tArray.append v1 v2 returns a fresh array containing the
concatenation of the arrays v1 and v2.val concat : 'a t list -> 'a tArray.append, but concatenates a list of arrays.val sub : 'a t -> pos:int -> len:int -> 'a tArray.sub a start len returns a fresh array of length len,
containing the elements number start to start + len - 1
of array a.
Raise Invalid_argument "Array.sub" if start and len do not
designate a valid subarray of a; that is, if
start < 0, or len < 0, or start + len > Array.length a.
val copy : 'a t -> 'a tArray.copy a returns a copy of a, that is, a fresh array
containing the same elements as a.val fill : 'a t -> pos:int -> len:int -> 'a -> unitArray.fill a ofs len x modifies the array a in place,
storing x in elements number ofs to ofs + len - 1.
Raise Invalid_argument "Array.fill" if ofs and len do not
designate a valid subarray of a.
val blit : src:'a t ->
src_pos:int -> dst:'a t -> dst_pos:int -> len:int -> unitArray.blit v1 o1 v2 o2 len copies len elements
from array v1, starting at element number o1, to array v2,
starting at element number o2. It works correctly even if
v1 and v2 are the same array, and the source and
destination chunks overlap.
Raise Invalid_argument "Array.blit" if o1 and len do not
designate a valid subarray of v1, or if o2 and len do not
designate a valid subarray of v2.
val of_list : 'a list -> 'a tArray.of_list l returns a fresh array containing the elements
of l.val map : f:('a -> 'b) -> 'a t -> 'b tArray.map ~f a applies function f to all the elements of a,
and builds an array with the results returned by f:
[| f a.(0); f a.(1); ...; f a.(Array.length a - 1) |].val iteri : f:(int -> 'a -> unit) -> 'a t -> unitArray.iter, but the
function is applied to the index of the element as first argument,
and the element itself as second argument.val mapi : f:(int -> 'a -> 'b) -> 'a t -> 'b tArray.map, but the
function is applied to the index of the element as first argument,
and the element itself as second argument.val foldi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b) -> 'bval fold_right : 'a t -> f:('a -> 'b -> 'b) -> init:'b -> 'bArray.fold_right f a ~init computes
f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...)),
where n is the length of the array a.val sort : cmp:('a -> 'a -> int) -> 'a t -> unitval stable_sort : cmp:('a -> 'a -> int) -> 'a t -> unitval is_sorted : 'a t -> cmp:('a -> 'a -> int) -> boolval concat_map : 'a t -> f:('a -> 'b array) -> 'b arrayval partition_tf : 'a t -> f:('a -> bool) -> 'a t * 'a tval partitioni_tf : 'a t -> f:(int -> 'a -> bool) -> 'a t * 'a tval cartesian_product : 'a t -> 'b t -> ('a * 'b) tval normalize : 'a t -> int -> intnormalize array index returns a new index into the array such that if index is less
than zero, the returned index will "wrap around" -- i.e. array.(normalize array (-1))
returns the last element of the array.val slice : 'a t -> int -> int -> 'a tslice array start stop returns a fresh array including elements array.(start)
through array.(stop-1) with the small tweak that the start and stop positions are
normalized and a stop index of 0 means the same thing a stop index of Array.length
array. In summary, it's mostly like the slicing in Python or Matlab. One difference
is that a stop value of 0 here is like not specifying a stop value in Python.val nget : 'a t -> int -> 'anormalized index.val nset : 'a t -> int -> 'a -> unitnormalized index.val filter_opt : 'a option t -> 'a tfilter_opt array returns a new array where None entries are omitted and Some x
entries are replaced with x. Note that this changes the index at which elements
will appear.val filter_map : 'a t -> f:('a -> 'b option) -> 'b tfilter_map ~f array maps f over array and filters None out of the results.val filter_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b tfilter_map but uses Array.mapi.val iter2_exn : 'a t -> 'b t -> f:('a -> 'b -> unit) -> unitval map2_exn : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c tval fold2_exn : 'a t ->
'b t -> init:'c -> f:('c -> 'a -> 'b -> 'c) -> 'cval for_all2_exn : 'a t -> 'b t -> f:('a -> 'b -> bool) -> boolfor_all2 t1 t2 ~f fails if length t1 <> length t2.val filter : f:('a -> bool) -> 'a t -> 'a tfilter ~f array removes the elements for which f returns false.val filteri : f:(int -> 'a -> bool) -> 'a t -> 'a tfilter except f also receives the index.val swap : 'a t -> int -> int -> unitswap arr i j swaps the value at index i with that at index j.val rev_inplace : 'a t -> unitrev_inplace t reverses t in placeval of_list_rev : 'a list -> 'a tof_list_rev l converts from list then reverses in placeval of_list_map : 'a list -> f:('a -> 'b) -> 'b tof_list_map l converts from list via fval of_list_rev_map : 'a list -> f:('a -> 'b) -> 'b tof_list_rev_map l converts from list via f then reverses in placeval replace : 'a t -> int -> f:('a -> 'a) -> unitreplace t i ~f = t.(i) <- f (t.(i)).val replace_all : 'a t -> f:('a -> 'a) -> unitar.(i) will be set to f(ar.(i))val find_exn : 'a t -> f:('a -> bool) -> 'afind_exn f t returns the first a in t for which f t.(i) is true.
It raises Not_found if there is no such a.val findi : 'a t -> f:(int -> 'a -> bool) -> (int * 'a) optionfindi t f returns the first index i of t for which f i t.(i) is trueval findi_exn : 'a t -> f:(int -> 'a -> bool) -> int * 'afindi_exn t f returns the first index i of t for which f i t.(i) is
true. It raises Not_found if there is no such element.val reduce : 'a t -> f:('a -> 'a -> 'a) -> 'a optionreduce f [a1; ...; an] is f (... (f (f a1 a2) a3) ...) an.val reduce_exn : 'a t -> f:('a -> 'a -> 'a) -> 'aval permute : ?random_state:Random.State.t -> 'a t -> unitpermute ?random_state t randomly permutes t in place.
permute side affects random_state by repeated calls to Random.State.int.
If random_state is not supplied, permute uses Random.State.default.
val combine : 'a t -> 'b t -> ('a * 'b) tcombine ar combines two arrays to an array of pairs.val split : ('a * 'b) t -> 'a t * 'b tsplit ar splits an array of pairs into two arrays of single elements.val sorted_copy : 'a t -> cmp:('a -> 'a -> int) -> 'a tsorted_copy ar cmp returns a shallow copy of ar that is sorted. Similar to
List.sortval last : 'a t -> 'aval empty : unit -> 'a tempty () creates an empty arrayval equal : 'a t -> 'a t -> equal:('a -> 'a -> bool) -> boolmodule Infix:sig..end
val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a tval sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.tval bin_t : 'a Bin_prot.Type_class.t -> 'a t Bin_prot.Type_class.tval bin_read_t : 'a Bin_prot.Unsafe_read_c.reader -> 'a t Bin_prot.Read_ml.readerval bin_read_t_ : 'a Bin_prot.Unsafe_read_c.reader ->
'a t Bin_prot.Unsafe_read_c.readerval bin_read_t__ : 'a Bin_prot.Unsafe_read_c.reader ->
(int -> 'a t) Bin_prot.Unsafe_read_c.readerval bin_reader_t : 'a Bin_prot.Type_class.reader -> 'a t Bin_prot.Type_class.readerval bin_size_t : 'a Bin_prot.Size.sizer -> 'a t Bin_prot.Size.sizerval bin_write_t : 'a Bin_prot.Unsafe_write_c.writer -> 'a t Bin_prot.Write_ml.writerval bin_write_t_ : 'a Bin_prot.Unsafe_write_c.writer ->
'a t Bin_prot.Unsafe_write_c.writerval bin_writer_t : 'a Bin_prot.Type_class.writer -> 'a t Bin_prot.Type_class.writer