Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • Community
  • X
  • Bluesky
  • GitHub
  • Forum
JS Module
Overview
  • JS
Submodules
  • Array2
  • Array
  • Console
  • Date
  • Dict
  • Exn
  • Float
  • Global
  • Int
  • Json
  • List
  • Math
  • NullUndefined
  • Null
  • Nullable
  • Obj
  • Option
  • Promise
  • Re
  • Result
  • String2
  • String
  • TypedArrayArrayBuffer
  • TypedArrayDataView
  • TypedArrayFloat32Array
  • TypedArrayFloat64Array
  • TypedArrayInt8Array
  • TypedArrayInt16Array
  • TypedArrayInt32Array
  • TypedArrayTypeS
  • TypedArrayUint8Array
  • TypedArrayUint8ClampedArray
  • TypedArrayUint16Array
  • TypedArrayUint32Array
  • TypedArray2ArrayBuffer
  • TypedArray2DataView
  • TypedArray2Float32Array
  • TypedArray2Float64Array
  • TypedArray2Int8Array
  • TypedArray2Int16Array
  • TypedArray2Int32Array
  • TypedArray2Uint8Array
  • TypedArray2Uint8ClampedArray
  • TypedArray2Uint16Array
  • TypedArray2Uint32Array
  • TypedArray2
  • TypedArray
  • Types
  • Undefined
  • Vector
    • t
    • append
    • copy
    • empty
    • filterInPlace
    • foldLeft
    • foldRight
    • get
    • init
    • iter
    • iteri
    • length
    • make
    • map
    • mapi
    • memByRef
    • pushBack
    • set
    • toList
    • unsafe_get
    • unsafe_set
API / Js / Vector

Vector

Provide vector utilities.

t

RES
type t<'a> = array<'a>

filterInPlace

RES
let filterInPlace: ((. 'a) => bool, t<'a>) => unit

p : predicate a : array

empty

RES
let empty: t<'a> => unit

pushBack

RES
let pushBack: ('a, t<'a>) => unit

copy

RES
let copy: t<'a> => t<'a>

Create a shallow copy of a vector.

memByRef

RES
let memByRef: ('a, t<'a>) => bool

Find by JS (===) equality.

iter

RES
let iter: ((. 'a) => unit, t<'a>) => unit

iteri

RES
let iteri: ((. int, 'a) => unit, t<'a>) => unit

toList

RES
let toList: t<'a> => list<'a>

map

RES
let map: ((. 'a) => 'b, t<'a>) => t<'b>

mapi

RES
let mapi: ((. int, 'a) => 'b, t<'a>) => t<'b>

foldLeft

RES
let foldLeft: ((. 'a, 'b) => 'a, 'a, t<'b>) => 'a

foldRight

RES
let foldRight: ((. 'b, 'a) => 'a, t<'b>, 'a) => 'a

length

RES
let length: t<'a> => int

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

get

RES
let 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

RES
let 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

RES
let 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

RES
let init: (int, (. int) => 'a) => t<'a>

Raises RangeError when n is negative. n : size

append

RES
let append: ('a, t<'a>) => t<'a>

append(x, a) returns a fresh vector with x appended to a.

unsafe_get

RES
let unsafe_get: (t<'a>, int) => 'a

unsafe_set

RES
let unsafe_set: (t<'a>, int, 'a) => unit

© 2025 The ReScript Project

Software and assets distribution powered by KeyCDN.

About
  • Community
  • ReScript Association
Find us on