module type intf = sig .. end
Common interface for array-like types (eg: string and bytes).
type t
t is the array type
type elt
elt is the element type
val length : Generic_core_desc.Array.intf.t -> int
Returns the length (number of elements) of the given array.
val get : Generic_core_desc.Array.intf.t -> int -> Generic_core_desc.Array.intf.elt
get a n returns the element at index n of array a.
The first element has index 0.
The last element has index length a - 1.
Raises Invalid_argument if n is outside the range 0 to (length a - 1).
val set : Generic_core_desc.Array.intf.t ->
int -> Generic_core_desc.Array.intf.elt -> unit
set a n x modifies array
a in place, replacing
element number
n with
x.
You can also write
a.(n) <- x instead of
set a n x.
RaisesInvalid_argument if n is outside the range 0 to length a - 1.
Failure if the array is not mutable.
val init : int ->
(int -> Generic_core_desc.Array.intf.elt) -> Generic_core_desc.Array.intf.t
init n f returns a fresh array of length n,
with element number i initialized to the result of f i.
In other terms, init n f tabulates the results of f
applied to the integers 0 to n-1.
Raises Invalid_argument if n < 0 or n > max_length.
val max_length : int
The maximum length that can be allocated for an array of type
t, using the function
init.
- if
t = string or bytes, max_length = Sys.max_string_length;
- if
t = float array, max_length = Sys.max_array_length / 2;
- if
t = elt array and elt isn't float, max_length = Sys.max_array_length.