import { List } from 'purify-ts/List'
List.at(0, [1, 2])
List.at(2, [1, 2])
➔
➔
Just(1)
Nothing
List.head([1])
List.head([])
➔
➔
Just(1)
Nothing
List.last([1, 2, 3])
List.last([])
➔
➔
Just(3)
Nothing
List.tail([1, 2, 3])
List.tail([1])
List.tail([])
➔
➔
➔
Just([2, 3])
Just([])
Nothing
List.init([1, 2, 3])
List.init([1])
List.init([])
➔
➔
➔
Just([1, 2])
Just([])
Nothing
List.find(x => x > 5, [1,3,7,9])
List.find(x => x > 5)([1,3,7,9])
List.find(x => x > 10, [1,3,7,9])
➔
➔
➔
Just(7)
Just(7)
Nothing
List.findIndex(x => x > 5, [1,3,7,9])
List.findIndex(x => x > 5)([1,3,7,9])
List.findIndex(x => x > 10, [1,3,7,9])
➔
➔
➔
Just(2)
Just(2)
Nothing
List.uncons([1, 2, 3])
List.uncons([1])
List.uncons([])
➔
➔
➔
Just(Tuple(1, [2, 3]))
Just(Tuple(1, []))
Nothing
List.sum([])
List.sum([1, 2, 3])
➔
➔
0
6
import { compare } from 'purify-ts/Function'
List.sort(compare, [1,100,-1])
import { Order } from 'purify-ts/Function'
List.sort((x, y) => /* your own fn */, [0,102,-223])
➔
➔
[-1, 1, 100]
// Result depends on the returned Order enum value (Order.LT, Order.EQ or Order.GT)