API / Js / List

List

Provide utilities for list

t

RESCRIPT
type t<'a> = list<'a>

length

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

cons

RESCRIPT
let cons: ('a, t<'a>) => t<'a>

isEmpty

RESCRIPT
let isEmpty: t<'a> => bool

hd

RESCRIPT
let hd: t<'a> => option<'a>

tl

RESCRIPT
let tl: t<'a> => option<t<'a>>

nth

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

revAppend

RESCRIPT
let revAppend: (t<'a>, t<'a>) => t<'a>

rev

RESCRIPT
let rev: t<'a> => t<'a>

mapRev

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

map

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

iter

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

iteri

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

foldLeft

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

Application order is left to right, tail recurisve

foldRight

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

Application order is right to left tail-recursive.

flatten

RESCRIPT
let flatten: t<t<'a>> => t<'a>

filter

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

filterMap

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

countBy

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

init

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

toVector

RESCRIPT
let toVector: t<'a> => array<'a>

equal

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