Module Prelude.Vector

See VECTOR.

type 'a t

The type of vectors.

val compare : 'a -> 'a -> int

compare is the version of compare for 'a t's.

val make : int -> 'a -> 'a t

(make n x) is a vector of size n with all elements equal to x.

val init : int -> (int -> 'a) -> 'a t

(init n f) is a vector of size n whose i'th element is (f i).

val random : ?size:(unit -> int) -> (unit -> 'a) -> unit -> 'a t
val get : int -> 'a t -> 'a

(get i v) is the i'th element of v.

val (#!) : 'a t -> int -> 'a

(v #! i) is (get i v).

val set : int -> 'a -> 'a t -> 'a t

(set i x v) is the vector v with the i'th element changed to x.

val len : 'a t -> int

(len v) is the length of vector v.

val update : ('a -> 'a) -> int -> 'a t -> 'a t

(update f i v) is the vector v with the i'th element changed to (f (get i v)).

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

(fold f acc v) folds f over vector v.

f is called as (f acc i) where acc is the accumulator and i is the current index.

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

(map f v) is the vector v' such that ∀i: (get i v') = (get i v |> f).

val mapi : (int -> 'a -> 'a) -> 'a t -> 'a t

(mapi f v) is the vector v' such that ∀i: (get i v') = (get i v |> f i).

val of_list : 'a list -> 'a t

(of_list l) is the vector v such that ∀i: (List.get i l) = (get i v).

val to_list : 'a t -> 'a list

(to_list v) is the list l such that ∀i: (get i v) = (List.get i l).

Ops

module Ops : sig ... end

Infix operators.