include Core.Array
This module extends Base.Array
.
Array
typeinclude sig ... end
val bin_t : 'a Bin_prot.Type_class.t ‑> 'a t Bin_prot.Type_class.t
val bin_read_t : 'a Bin_prot.Read.reader ‑> 'a t Bin_prot.Read.reader
val __bin_read_t__ : 'a Bin_prot.Read.reader ‑> (Core_kernel__.Import.int ‑> 'a t) Bin_prot.Read.reader
val bin_reader_t : 'a Bin_prot.Type_class.reader ‑> 'a t Bin_prot.Type_class.reader
val bin_size_t : 'a Bin_prot.Size.sizer ‑> 'a t Bin_prot.Size.sizer
val bin_write_t : 'a Bin_prot.Write.writer ‑> 'a t Bin_prot.Write.writer
val bin_writer_t : 'a Bin_prot.Type_class.writer ‑> 'a t Bin_prot.Type_class.writer
val bin_shape_t : Bin_prot.Shape.t ‑> Bin_prot.Shape.t
val typerep_of_t : 'a Typerep_lib.Std.Typerep.t ‑> 'a t Typerep_lib.Std.Typerep.t
val typename_of_t : 'a Typerep_lib.Std.Typename.t ‑> 'a t Typerep_lib.Std.Typename.t
Base.Array
include module type of sig ... end with type a t := a t
val t_of_sexp : (Base.Sexp.t ‑> 'a) ‑> Base.Sexp.t ‑> 'a t
val sexp_of_t : ('a ‑> Base.Sexp.t) ‑> 'a t ‑> Base.Sexp.t
val binary_search : ('a t, 'a, 'key) Base__.Binary_searchable_intf.binary_search
val binary_search_segmented : ('a t, 'a) Base__.Binary_searchable_intf.binary_search_segmented
val mem : 'a t ‑> 'a ‑> equal:('a ‑> 'a ‑> bool) ‑> bool
val length : 'a t ‑> int
val is_empty : 'a t ‑> bool
val iter : 'a t ‑> f:('a ‑> unit) ‑> unit
val fold : 'a t ‑> init:'accum ‑> f:('accum ‑> 'a ‑> 'accum) ‑> 'accum
val fold_result : 'a t ‑> init:'accum ‑> f:('accum ‑> 'a ‑> ('accum, 'e) Base.Result.t) ‑> ('accum, 'e) Base.Result.t
val fold_until : 'a t ‑> init:'accum ‑> f:('accum ‑> 'a ‑> ('accum, 'final) Base__.Container_intf.Continue_or_stop.t) ‑> finish:('accum ‑> 'final) ‑> 'final
val exists : 'a t ‑> f:('a ‑> bool) ‑> bool
val for_all : 'a t ‑> f:('a ‑> bool) ‑> bool
val count : 'a t ‑> f:('a ‑> bool) ‑> int
val sum : (module Base.Commutative_group.S with type t = 'sum) ‑> 'a t ‑> f:('a ‑> 'sum) ‑> 'sum
val find : 'a t ‑> f:('a ‑> bool) ‑> 'a option
val find_map : 'a t ‑> f:('a ‑> 'b option) ‑> 'b option
val to_list : 'a t ‑> 'a list
val to_array : 'a t ‑> 'a array
val min_elt : 'a t ‑> compare:('a ‑> 'a ‑> int) ‑> 'a option
val max_elt : 'a t ‑> compare:('a ‑> 'a ‑> int) ‑> 'a option
val invariant : 'a Base__.Invariant_intf.inv ‑> 'a t Base__.Invariant_intf.inv
external get : 'a t ‑> int ‑> 'a = "%array_safe_get"
external set : 'a t ‑> int ‑> 'a ‑> unit = "%array_safe_set"
external unsafe_get : 'a t ‑> int ‑> 'a = "%array_unsafe_get"
external unsafe_set : 'a t ‑> int ‑> 'a ‑> unit = "%array_unsafe_set"
val create : len:int ‑> 'a ‑> 'a t
val init : int ‑> f:(int ‑> 'a) ‑> 'a t
val fill : 'a t ‑> pos:int ‑> len:int ‑> 'a ‑> unit
val blit : ('a t, 'a t) Base__.Blit_intf.blit
val blito : ('a t, 'a t) Base__.Blit_intf.blito
val unsafe_blit : ('a t, 'a t) Base__.Blit_intf.blit
val sub : ('a t, 'a t) Base__.Blit_intf.sub
val subo : ('a t, 'a t) Base__.Blit_intf.subo
val of_list : 'a list ‑> 'a t
val iteri : 'a t ‑> f:(int ‑> 'a ‑> unit) ‑> unit
val foldi : 'a t ‑> init:'b ‑> f:(int ‑> 'b ‑> 'a ‑> 'b) ‑> 'b
val fold_right : 'a t ‑> f:('a ‑> 'b ‑> 'b) ‑> init:'b ‑> 'b
val sort : ?pos:int ‑> ?len:int ‑> 'a t ‑> compare:('a ‑> 'a ‑> int) ‑> unit
val stable_sort : 'a t ‑> compare:('a ‑> 'a ‑> int) ‑> unit
val is_sorted : 'a t ‑> compare:('a ‑> 'a ‑> int) ‑> bool
val is_sorted_strictly : 'a t ‑> compare:('a ‑> 'a ‑> int) ‑> bool
val concat_map : 'a t ‑> f:('a ‑> 'b array) ‑> 'b array
val concat_mapi : 'a t ‑> f:(int ‑> 'a ‑> 'b array) ‑> 'b array
val for_alli : 'a t ‑> f:(int ‑> 'a ‑> bool) ‑> bool
val existsi : 'a t ‑> f:(int ‑> 'a ‑> bool) ‑> bool
val counti : 'a t ‑> f:(int ‑> 'a ‑> bool) ‑> int
val swap : 'a t ‑> int ‑> int ‑> unit
val rev_inplace : 'a t ‑> unit
val of_list_rev : 'a list ‑> 'a t
val of_list_map : 'a list ‑> f:('a ‑> 'b) ‑> 'b t
val of_list_rev_map : 'a list ‑> f:('a ‑> 'b) ‑> 'b t
val replace : 'a t ‑> int ‑> f:('a ‑> 'a) ‑> unit
val map_inplace : 'a t ‑> f:('a ‑> 'a) ‑> unit
val find_exn : 'a t ‑> f:('a ‑> bool) ‑> 'a
val find_map_exn : 'a t ‑> f:('a ‑> 'b option) ‑> 'b
val findi : 'a t ‑> f:(int ‑> 'a ‑> bool) ‑> (int * 'a) option
val findi_exn : 'a t ‑> f:(int ‑> 'a ‑> bool) ‑> int * 'a
val find_mapi : 'a t ‑> f:(int ‑> 'a ‑> 'b option) ‑> 'b option
val find_mapi_exn : 'a t ‑> f:(int ‑> 'a ‑> 'b option) ‑> 'b
val find_consecutive_duplicate : 'a t ‑> equal:('a ‑> 'a ‑> bool) ‑> ('a * 'a) option
val reduce : 'a t ‑> f:('a ‑> 'a ‑> 'a) ‑> 'a option
val reduce_exn : 'a t ‑> f:('a ‑> 'a ‑> 'a) ‑> 'a
val permute : ?random_state:Base.Random.State.t ‑> 'a t ‑> unit
val random_element : ?random_state:Base.Random.State.t ‑> 'a t ‑> 'a option
val random_element_exn : ?random_state:Base.Random.State.t ‑> 'a t ‑> 'a
val last : 'a t ‑> 'a
val unsafe_truncate : 'a t ‑> len:int ‑> unit
val to_sequence : 'a t ‑> 'a Base.Sequence.t
val to_sequence_mutable : 'a t ‑> 'a Base.Sequence.t
module Private = Base__Array.Private
We add extensions for Int
and Float
arrays to make them bin-able, comparable,
sexpable, and blit-able (via Blit.S
). Permissioned
provides fine-grained access
control for arrays.
Operations supporting "normalized" indexes are also available.
module Int = Core_kernel.Array.Int
module Float = Core_kernel.Array.Float
val normalize : 'a t ‑> Core_kernel__.Import.int ‑> Core_kernel__.Import.int
normalize array index
returns a new index into the array such that if the 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 ‑> Core_kernel__.Import.int ‑> Core_kernel__.Import.int ‑> 'a t
slice t start stop
returns a new array including elements t.(start)
through
t.(stop-1)
, normalized Python-style with the exception that stop = 0
is treated as
stop = length t
.
val nset : 'a t ‑> Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.unit
Array modification with normalize
d index.
module Permissioned = Core_kernel.Array.Permissioned
The Permissioned
module gives the ability to restrict permissions on an array, so
you can give a function read-only access to an array, create an immutable array, etc.
include Extended_array
val random_split : ?random_state:Core.Random.State.t ‑> 'a array ‑> p:float ‑> 'a array * 'a array
makes a random split & subset of an array; p (the fraction that you want to split) is
constrained to be 0, 1
. Note that the length of the first array will be the closest
integer to the fraction you desired, meaning that each element is NOT selected with
probability exactly p.
val random_sub : ?random_state:Core.Random.State.t ‑> 'a array ‑> p:float ‑> 'a array