package containers

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a t

A view on an array or part of an array

val of_array : ('a, _, [> `R ]) array_ -> 'a t
val get : 'a t -> int -> 'a

get v i returns the i-th element of v. Caution, this is not as cheap as a regular array indexing, and it might involve recursion.

  • raises Invalid_argument

    if index out of bounds

val length : _ t -> int

length v is the number of elements of v

val map : f:('a -> 'b) -> 'a t -> 'b t

Map values

val map2 : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

Map values

val select : idx:(int, _, [> `R ]) array_ -> 'a t -> 'a t

select ~idx v is the view that has length length idx and such that get (select ~idx a) i = get a (get idx i)

val select_a : idx:int array -> 'a t -> 'a t

See select

val select_view : idx:int t -> 'a t -> 'a t

See select

val foldi : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b

Fold on values with their index

val iteri : f:(int -> 'a -> unit) -> 'a t -> unit

iteri ~f v iterates on elements of v with their index

module type S = sig ... end
module Int : sig ... end
module Float : sig ... end
val raw : length:(('a, 'b, [> `R ]) array_ -> int) -> get:(('a, 'b, [> `R ]) array_ -> int -> 'a) -> ('a, 'b, [> `R ]) array_ -> 'a t
val to_array : ?res:('a, 'b, [> `W ] as 'perm) array_ -> ?kind:('a, 'b) Bigarray.kind -> 'a t -> ('a, 'b, 'perm) array_

to_array v returns a fresh copy of the content of v. Exactly one of res and kind must be provided

OCaml

Innovation. Community. Security.