Module Core_kernel.Array
This module extends Base.Array.
The Array type
type 'a t= 'a Base.Array.t
include Bin_prot.Binable.S1 with type 'a t := 'a t
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.tval bin_size_t : ('a, 'a t) Bin_prot.Size.sizer1val bin_write_t : ('a, 'a t) Bin_prot.Write.writer1val bin_read_t : ('a, 'a t) Bin_prot.Read.reader1val __bin_read_t__ : ('a, int -> 'a t) Bin_prot.Read.reader1val bin_writer_t : ('a, 'a t) Bin_prot.Type_class.S1.writerval bin_reader_t : ('a, 'a t) Bin_prot.Type_class.S1.readerval bin_t : ('a, 'a t) Bin_prot.Type_class.S1.t
include Typerep_lib.Typerepable.S1 with type 'a t := 'a t
val typerep_of_t : 'a Typerep_lib.Std_internal.Typerep.t -> 'a t Typerep_lib.Std_internal.Typerep.tval typename_of_t : 'a Typerep_lib.Typename.t -> 'a t Typerep_lib.Typename.t
The signature included from Base.Array
include module type of sig ... end with type 'a t := 'a t
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> intval t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a tval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.tval t_sexp_grammar : Base.Sexp.Private.Raw_grammar.tval binary_search : ('a t, 'a, 'key) Base__.Binary_searchable_intf.binary_searchval binary_search_segmented : ('a t, 'a) Base__.Binary_searchable_intf.binary_search_segmentedval mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> boolval length : 'a t -> intval is_empty : 'a t -> boolval iter : 'a t -> f:('a -> unit) -> unitval fold : 'a t -> init:'accum -> f:('accum -> 'a -> 'accum) -> 'accumval fold_result : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'e) Base.Result.t) -> ('accum, 'e) Base.Result.tval fold_until : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'final) Base__.Container_intf.Continue_or_stop.t) -> finish:('accum -> 'final) -> 'finalval exists : 'a t -> f:('a -> bool) -> boolval for_all : 'a t -> f:('a -> bool) -> boolval count : 'a t -> f:('a -> bool) -> intval sum : (module Base__.Container_intf.Summable with type t = 'sum) -> 'a t -> f:('a -> 'sum) -> 'sumval find : 'a t -> f:('a -> bool) -> 'a optionval find_map : 'a t -> f:('a -> 'b option) -> 'b optionval to_list : 'a t -> 'a listval to_array : 'a t -> 'a arrayval min_elt : 'a t -> compare:('a -> 'a -> int) -> 'a optionval max_elt : 'a t -> compare:('a -> 'a -> int) -> 'a optionval invariant : 'a Base__.Invariant_intf.inv -> 'a t Base__.Invariant_intf.invval max_length : int
val get : 'a t -> int -> 'aval set : 'a t -> int -> 'a -> unitval unsafe_get : 'a t -> int -> 'aval unsafe_set : 'a t -> int -> 'a -> unit
val create : len:int -> 'a -> 'a tval init : int -> f:(int -> 'a) -> 'a tval make_matrix : dimx:int -> dimy:int -> 'a -> 'a t tval append : 'a t -> 'a t -> 'a tval concat : 'a t list -> 'a tval copy : 'a t -> 'a tval fill : 'a t -> pos:int -> len:int -> 'a -> unitval blit : ('a t, 'a t) Base__.Blit_intf.blitval blito : ('a t, 'a t) Base__.Blit_intf.blitoval unsafe_blit : ('a t, 'a t) Base__.Blit_intf.blitval sub : ('a t, 'a t) Base__.Blit_intf.subval subo : ('a t, 'a t) Base__.Blit_intf.suboval of_list : 'a list -> 'a tval map : 'a t -> f:('a -> 'b) -> 'b tval folding_map : 'a t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> 'c tval folding_mapi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b * 'c) -> 'c tval fold_map : 'a t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> 'b * 'c tval fold_mapi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b * 'c) -> 'b * 'c tval iteri : 'a t -> f:(int -> 'a -> unit) -> unitval mapi : 'a t -> f:(int -> 'a -> 'b) -> 'b tval foldi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b) -> 'bval fold_right : 'a t -> f:('a -> 'b -> 'b) -> init:'b -> 'bval sort : ?pos:int -> ?len:int -> 'a t -> compare:('a -> 'a -> int) -> unitval stable_sort : 'a t -> compare:('a -> 'a -> int) -> unitval is_sorted : 'a t -> compare:('a -> 'a -> int) -> boolval is_sorted_strictly : 'a t -> compare:('a -> 'a -> int) -> boolval concat_map : 'a t -> f:('a -> 'b array) -> 'b arrayval concat_mapi : 'a t -> f:(int -> '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 transpose : 'a t t -> 'a t t optionval transpose_exn : 'a t t -> 'a t tval filter_opt : 'a option t -> 'a tval filter_map : 'a t -> f:('a -> 'b option) -> 'b tval filter_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b tval for_alli : 'a t -> f:(int -> 'a -> bool) -> boolval existsi : 'a t -> f:(int -> 'a -> bool) -> boolval counti : 'a t -> f:(int -> 'a -> bool) -> intval 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) -> boolval exists2_exn : 'a t -> 'b t -> f:('a -> 'b -> bool) -> boolval filter : 'a t -> f:('a -> bool) -> 'a tval filteri : 'a t -> f:(int -> 'a -> bool) -> 'a tval swap : 'a t -> int -> int -> unitval rev_inplace : 'a t -> unitval of_list_rev : 'a list -> 'a tval of_list_map : 'a list -> f:('a -> 'b) -> 'b tval of_list_mapi : 'a list -> f:(int -> 'a -> 'b) -> 'b tval of_list_rev_map : 'a list -> f:('a -> 'b) -> 'b tval of_list_rev_mapi : 'a list -> f:(int -> 'a -> 'b) -> 'b tval map_inplace : 'a t -> f:('a -> 'a) -> unitval find_exn : 'a t -> f:('a -> bool) -> 'aval find_map_exn : 'a t -> f:('a -> 'b option) -> 'bval findi : 'a t -> f:(int -> 'a -> bool) -> (int * 'a) optionval findi_exn : 'a t -> f:(int -> 'a -> bool) -> int * 'aval find_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b optionval find_mapi_exn : 'a t -> f:(int -> 'a -> 'b option) -> 'bval find_consecutive_duplicate : 'a t -> equal:('a -> 'a -> bool) -> ('a * 'a) optionval reduce : 'a t -> f:('a -> 'a -> 'a) -> 'a optionval reduce_exn : 'a t -> f:('a -> 'a -> 'a) -> 'aval permute : ?random_state:Base.Random.State.t -> 'a t -> unitval random_element : ?random_state:Base.Random.State.t -> 'a t -> 'a optionval random_element_exn : ?random_state:Base.Random.State.t -> 'a t -> 'aval zip : 'a t -> 'b t -> ('a * 'b) t optionval zip_exn : 'a t -> 'b t -> ('a * 'b) tval unzip : ('a * 'b) t -> 'a t * 'b tval sorted_copy : 'a t -> compare:('a -> 'a -> int) -> 'a tval last : 'a t -> 'aval equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> boolval to_sequence : 'a t -> 'a Base.Sequence.tval to_sequence_mutable : 'a t -> 'a Base.Sequence.t
module Private = Base__Array.PrivateExtensions
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 : sig ... endmodule Float : sig ... endval normalize : 'a t -> Core_kernel__.Import.int -> Core_kernel__.Import.intnormalize array indexreturns 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 tslice t start stopreturns a new array including elementst.(start)throught.(stop-1), normalized Python-style with the exception thatstop = 0is treated asstop = length t.
val nget : 'a t -> Core_kernel__.Import.int -> 'aArray access with
normalized index.
val nset : 'a t -> Core_kernel__.Import.int -> 'a -> Core_kernel__.Import.unitArray modification with
normalized index.
module Permissioned : sig ... endThe
Permissionedmodule 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.