You are currently looking at the < v8.2.0 docs (Reason v3.6 syntax edition). You can find the latest API docs here.
(These docs cover all versions between v3 to v8 and are equivalent to the old BuckleScript docs before the rebrand)
Vector
Provide vector utilities.
t
REtype t('a) = array('a);
filterInPlace
RElet filterInPlace: ((. 'a) => bool, t('a)) => unit;
p : predicate a : array
empty
RElet empty: t('a) => unit;
pushBack
RElet pushBack: ('a, t('a)) => unit;
copy
RElet copy: t('a) => t('a);
Create a shallow copy of a vector.
memByRef
RElet memByRef: ('a, t('a)) => bool;
Find by JS (===) equality.
iter
RElet iter: ((. 'a) => unit, t('a)) => unit;
iteri
RElet iteri: ((. int, 'a) => unit, t('a)) => unit;
toList
RElet toList: t('a) => list('a);
map
RElet map: ((. 'a) => 'b, t('a)) => t('b);
mapi
RElet mapi: ((. int, 'a) => 'b, t('a)) => t('b);
foldLeft
RElet foldLeft: ((. 'a, 'b) => 'a, 'a, t('b)) => 'a;
foldRight
RElet foldRight: ((. 'b, 'a) => 'a, t('b), 'a) => 'a;
length
RElet length: t('a) => int;
Return the length (number of elements) of the given array.
get
RElet get: (t('a), int) => 'a;
Vector.get(a, n)
returns the element number n
of vector a
. The first element has number 0. The last element has number Vector.length(a) - 1
. You can also write a[n]
instead of Vector.get(a, n)
.
Raise Invalid_argument "index out of bounds"
if n
is outside the range 0 to (Array.length(a) - 1
).
set
RElet set: (t('a), int, 'a) => unit;
Vector.set(a, n, x)
modifies vector a
in place, replacing element number n
with x
.
Raise Invalid_argument "index out of bounds"
if n
is outside the range 0 to Array.length(a) - 1
.
make
RElet make: (int, 'a) => t('a);
Vector.make(n, x)
returns a fresh vector of length n
, initialized with x
. All the elements of this new vector 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
.
init
RElet init: (int, (. int) => 'a) => t('a);
Raises RangeError
when n is negative.
n : size
append
RElet append: ('a, t('a)) => t('a);
append(x, a)
returns a fresh vector with x
appended to a
.
unsafe_get
RElet unsafe_get: (t('a), int) => 'a;
unsafe_set
RElet unsafe_set: (t('a), int, 'a) => unit;