Module Js.Vector

type t('a) = array('a);
module Js := Js__.Js_internal
let filterInPlace: Js.Fn.arity1(('a => bool)) => t('a) => unit;
let empty: t('a) => unit;
let pushBack: 'a => t('a) => unit;
let copy: t('a) => t('a);

shallow copy

let memByRef: 'a => t('a) => bool;
let iter: Js.Fn.arity1(('a => unit)) => t('a) => unit;
let iteri: Js.Fn.arity2((int => 'a => unit)) => t('a) => unit;
let toList: t('a) => list('a);
let map: Js.Fn.arity1(('a => 'b)) => t('a) => t('b);
let mapi: Js.Fn.arity2((int => 'a => 'b)) => t('a) => t('b);
let foldLeft: Js.Fn.arity2(('a => 'b => 'a)) => 'a => t('b) => 'a;
let foldRight: Js.Fn.arity2(('b => 'a => 'a)) => t('b) => 'a => 'a;
let length: t('a) => int;

Return the length (number of elements) of the given array.

let get: t('a) => int => 'a;

Array.get a n returns the element number n of array a. The first element has number 0. The last element has number Array.length a - 1. You can also write a.(n) instead of Array.get a n.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to (Array.length a - 1).

let set: t('a) => int => 'a => unit;

Array.set a n x modifies array a in place, replacing element number n with x. You can also write a.(n) <- x instead of Array.set a n x.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to Array.length a - 1.

let make: int => 'a => t('a);

Array.make n x returns a fresh array of length n, initialized with x. All the elements of this new array are initially physically equal to x (in the sense of the == predicate). Consequently, if x is mutable, it is shared among all elements of the array, and modifying x through one of the array entries will modify all other entries at the same time.

Raise Invalid_argument if n < 0 or n > Sys.max_array_length. If the value of x is a floating-point number, then the maximum size is only Sys.max_array_length / 2.

let init: int => Js.Fn.arity1((int => 'a)) => t('a);
  • parameter n

    size

  • parameter fn

    callback

  • raises RangeError

    when n is negative

let append: 'a => t('a) => t('a);

append x a returns a fresh array with x appended to a

let unsafe_get: t('a) => int => 'a;
let unsafe_set: t('a) => int => 'a => unit;