API / Js / List

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)

List

Provide utilities for list.

t

type t('a) = list('a);

length

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

cons

let cons: ('a, t('a)) => t('a);

isEmpty

let isEmpty: t('a) => bool;

hd

let hd: t('a) => option('a);

tl

let tl: t('a) => option(t('a));

nth

let nth: (t('a), int) => option('a);

revAppend

let revAppend: (t('a), t('a)) => t('a);

rev

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

mapRev

let mapRev: ((. 'a) => 'b, t('a)) => t('b);

map

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

iter

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

iteri

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

foldLeft

let foldLeft: ((. 'a, 'b) => 'a, 'a, list('b)) => 'a;

Application order is left to right, tail-recurisve.

foldRight

let foldRight: ((. 'a, 'b) => 'b, list('a), 'b) => 'b;

Application order is right to left, tail-recursive.

flatten

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

filter

let filter: ((. 'a) => bool, t('a)) => t('a);

filterMap

let filterMap: ((. 'a) => option('b), t('a)) => t('b);

countBy

let countBy: ((. 'a) => bool, list('a)) => int;

init

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

toVector

let toVector: t('a) => Js_vector.t('a);

equal

let equal: ((. 'a, 'a) => bool, list('a), list('a)) => bool;