Base.IarraySourceinclude sig ... endval sexp_of_t :
('a : value_or_null mod separable). ('a -> Sexplib0.Sexp.t) ->
'a t ->
Sexplib0.Sexp.tval sexp_of_t__stack :
('a : value_or_null mod separable). ('a @ local -> Sexplib0.Sexp.t @ local) ->
'a t @ local ->
Sexplib0.Sexp.t @ localval t_of_sexp :
('a : value_or_null mod separable). (Sexplib0.Sexp.t -> 'a) ->
Sexplib0.Sexp.t ->
'a tval t_sexp_grammar :
('a : value_or_null mod separable). 'a Sexplib0.Sexp_grammar.t ->
'a t Sexplib0.Sexp_grammar.t @@ portableinclude sig ... endinclude Ppx_hash_lib.Hashable.S1 with type 'a t := 'a tStandard interfaces
include Binary_searchable.S1__local with type 'a t := 'a tSee Binary_search.binary_search in binary_search.ml
See Binary_search.binary_search_segmented in binary_search.ml
include Indexed_container.S1_with_creators__''value_or_null''__stack
with type ('a : any) t := 'a tinclude Container.S1__''value_or_null''__stack with type ('a : any) t := 'a tinclude sig ... endinclude sig ... endThese are all like their equivalents in Container except that an index starting at 0 is added as the first argument to f.
val existsi :
('a : value_or_null mod separable) 'p1 'p2. ('a, 'p1, 'p2)
{t}45/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}46/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
bool) @ local) @ local ->
boolval for_alli :
('a : value_or_null mod separable) 'p1 'p2. ('a, 'p1, 'p2)
{t}45/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}46/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
bool) @ local) @ local ->
boolval counti :
('a : value_or_null mod separable) 'p1 'p2. ('a, 'p1, 'p2)
{t}45/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}46/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
bool) @ local) @ local ->
intval iteri_until :
('a : value_or_null mod separable) 'p1 'p2 ('final : value_or_null).
('a, 'p1, 'p2) {t}45/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}46/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
(unit, 'final) Container.Continue_or_stop.t) @ local) @ local ->
finish:(int -> 'final) @ local ->
'finalval find_mapi :
('a : value_or_null mod separable) 'p1 'p2 ('b : value_or_null). ('a,
'p1,
'p2)
{t}45/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}46/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
'b option) @ local) @ local ->
'b optionval foldi_until :
('a : value_or_null mod separable) 'p1 'p2 ('acc : value_or_null) ('final : value_or_null).
('a, 'p1, 'p2) {t}45/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
init:'acc ->
f:
(int ->
('acc ->
('a {elt}46/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
('acc, 'final) Container.Continue_or_stop.t) @ local) @ local) @ local ->
finish:(int -> ('acc -> 'final) @ local) @ local ->
'finalval findi :
('a : value_or_null mod separable) 'p1 'p2. ('a, 'p1, 'p2) t ->
f:(int -> ('a elt -> bool) @ local) @ local ->
(int * 'a elt) optioninclude Container.S1_with_creators__''value_or_null''__stack
with type ('a : value_or_null mod separable) t := 'a tinclude sig ... endval exists :
('a : value_or_null mod separable) 'p1 'p2. 'a t ->
f:('a -> bool) @ local ->
boolReturns true if and only if there exists an element for which the provided function evaluates to true. This is a short-circuiting operation.
Returns the number of elements for which the provided function evaluates to true.
val find :
('a : value_or_null mod separable) 'p1 'p2. 'a t ->
f:('a -> bool) @ local ->
'a optionReturns as an option the first element for which f evaluates to true.
val min_elt :
('a : value_or_null mod separable) 'p1 'p2. 'a t ->
compare:('a -> ('a -> int) @ local) @ local ->
'a optionReturns a min (resp. max) element from the collection using the provided compare function. In case of a tie, the first element encountered while traversing the collection is returned. The implementation uses fold so it has the same complexity as fold. Returns None iff the collection is empty.
val sum :
('a : value_or_null mod separable) ('sum : value_or_null) 'p1 'p2.
(module Container.Summable
with type t = 'sum) ->
'a t ->
f:('a -> 'sum) @ local ->
'sumReturns the sum of f i for all i in the container. The order in which the elements will be summed is unspecified.
val iter_until :
('a : value_or_null mod separable) 'p1 'p2 ('final : value_or_null).
'a t ->
f:('a -> (unit, 'final) Container.Continue_or_stop.t) @ local ->
finish:(unit -> 'final) @ local ->
'finaliter_until t ~f ~finish is a short-circuiting version of iter. If f returns Stop x the computation ceases and returns x. If f always returns Continue () the final result is computed by finish.
val fold_result :
('a : value_or_null mod separable) 'p1 'p2 ('acc : value_or_null) 'e.
'a t ->
init:'acc ->
f:('acc -> ('a -> ('acc, 'e) result) @ local) @ local ->
('acc, 'e) resultfold_result t ~init ~f is a short-circuiting version of fold that runs in the Result monad. If f returns an Error _, that value is returned without any additional invocations of f.
include sig ... endval fold_until :
('a : value_or_null mod separable) 'p1 'p2 ('acc : value_or_null) ('final : value_or_null).
'a t ->
init:'acc ->
f:
('acc -> ('a -> ('acc, 'final) Container.Continue_or_stop.t) @ local) @ local ->
finish:('acc -> 'final) @ local ->
'finalfold_until t ~init ~f ~finish is a short-circuiting version of fold. If f returns Stop _ the computation ceases and results in that value. If f returns Continue _, the fold will proceed. If f never returns Stop _, the final result is computed by finish.
Example:
type maybe_negative =
| Found_negative of int
| All_nonnegative of { sum : int }
(** [first_neg_or_sum list] returns the first negative number in [list], if any,
otherwise returns the sum of the list. *)
let first_neg_or_sum =
List.fold_until ~init:0
~f:(fun sum x ->
if x < 0
then Stop (Found_negative x)
else Continue (sum + x))
~finish:(fun sum -> All_nonnegative { sum })
;;
let x = first_neg_or_sum [1; 2; 3; 4; 5]
val x : maybe_negative = All_nonnegative {sum = 15}
let y = first_neg_or_sum [1; 2; -3; 4; 5]
val y : maybe_negative = Found_negative -3val mem :
('a : value_or_null mod separable) 'p1 'p2. 'a t ->
'a ->
equal:('a -> ('a -> bool) @ local) @ local ->
boolChecks whether the provided element is there, using equal.
include sig ... endE.g., append (of_list [a; b]) (of_list [c; d; e]) is of_list [a; b; c; d; e]
Concatenates a nested container. The elements of the inner containers are concatenated together in order to give the result.
val filter :
('a : value_or_null mod separable) 'p1 'p2. 'a t ->
f:('a -> bool) @ local ->
'a tfilter t ~f returns all the elements of t that satisfy the predicate f.
val partition_tf :
('a : value_or_null mod separable) 'p1 'p2. 'a t ->
f:('a -> bool) @ local ->
'a t * 'a tpartition_tf t ~f returns a pair t1, t2, where t1 is all elements of t that satisfy f, and t2 is all elements of t that do not satisfy f. The "tf" suffix is mnemonic to remind readers that the result is (trues, falses).
val filteri :
('a : value_or_null mod separable) 'p1 'p2. ('a, 'p1, 'p2)
{t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
bool) @ local) @ local ->
('a, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)val partitioni_tf :
('a : value_or_null mod separable) 'p1 'p2. ('a, 'p1, 'p2)
{t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
bool) @ local) @ local ->
('a, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)
* ('a, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)partitioni_tf t ~f is like partition_tf. Additionally, it passes the index as an argument.
val filter_mapi :
('a : value_or_null mod separable) 'p1 'p2 ('b : value_or_null mod separable).
('a, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
'b {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) option) @ local) @ local ->
('b, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)filter_mapi is like filter_map. Additionally, it passes in the index of each element as the first argument to the mapped function.
val concat_mapi :
('a : value_or_null mod separable) 'p1 'p2 ('b : value_or_null mod separable).
('a, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
('b, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)) @ local) @ local ->
('b, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)concat_mapi t ~f is like concat_map. Additionally, it passes the index as an argument.
val partition_mapi :
('a : value_or_null mod separable) 'p1 'p2 ('b : value_or_null mod separable) ('c : value_or_null mod separable).
('a, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
f:
(int ->
('a {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca) ->
('b {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca),
'c {elt}366/shadowed/(8f9e3060c4c689c937aa7d214ca25fca))
Base__.Either0.t) @ local) @ local ->
('b, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)
* ('c, 'p1, 'p2) {t}365/shadowed/(8f9e3060c4c689c937aa7d214ca25fca)partition_mapi t ~f is like partition_map. Additionally, it passes the index as an argument.
Like find but returning or_null instead of option.
Like findi but returning or_null instead of option.
Like find_map but with a function returning or_null instead of option.
val find_mapi_or_null :
'a 'b. 'a t ->
f:(int -> ('a -> 'b or_null) @ local) @ local ->
'b or_nullLike find_mapi but with a function returning or_null instead of option.
include Invariant.S1 with type 'a t := 'a tOperators
An alias for get.
Indexing
include sig ... endFunctional update
Constructors
val create :
len:int ->
'a ->
mutate:('a array @ local -> unit) @ local ->
'a Basement.Stdlib_iarray_labels.tConversions
Subsequences
split_n t n returns a pair of iarrays (first, second) where first contains the first n elements of t and second contains the remaining elements.
n >= length t, returns (t, empty).n <= 0, returns (empty, t).chunks_of t ~length returns an iarray of iarrays whose concatenation is equal to the original iarray. Every iarray has length elements, except for possibly the last iarray, which may have fewer. chunks_of raises if length <= 0.
Reordering
Combining elements
Multiple arrays
Random elements
Blit operations
Unsafe conversions
Immutable arrays can be converted to and from mutable arrays, as they can have the same representation. One must be careful not to modify the mutable array sharing a representation with an immutable array at any time when both are reachable. Doing so violates the invariants of the immutable array. The OCaml compiler might rely on these invariants when compiling or optimizing code that uses immutable arrays.