Module: list/building

Methods

(static) scanl(f, q, ls) → {List}

Scan a List from the right to left and return a List of successive reduced values.
Haskell> scanl :: (b -> a -> b) -> b -> [a] -> [b]

Parameters:
Name Type Description
f function

The function to map over the List

q *

An accumulator value

ls List

The List to scan

Source:
Returns:

The List of reduced values

Type
List
Example
const lst = list(1,2,3);
const f = (x, y) => x - y;
scanl(f, 0, lst);          // => [0:-1:-3:-6:[]]

(static) scanr(f, q0, as) → {List}

Like scanl but scans left to right instead of right to left.
Haskell> scanr :: (a -> b -> b) -> b -> [a] -> [b]

Parameters:
Name Type Description
f function

The function to map over the List

q0 *

An accumulator value

as List

The List to scan

Source:
Returns:

The List of reduced values

Type
List
Example
const lst = list(1,2,3);
const f = (x, y) => x - y;
scanr(f, 0, lst);          // => [2:-1:3:0:[]]