Module: list/folds

Methods

(static) concat(xss) → {List}

Concatenate the elements in a container of lists. Currently, this function only works on List objects, though it should in the future work on all Foldable types.
Haskell> concat :: Foldable t => t [a] -> [a]

Parameters:
Name Type Description
xss List

A List of lists

Source:
Returns:

The concatenated List

Type
List
Example
const lst1 = list(1,2,3);
const lst2 = list(4,5,6);
const lst3 = list(7,8,9);
const xss = list(lst1, lst2, lst3); // [[1:2:3:[]]:[4:5:6:[]]:[7:8:9:[]]:[]]
concat(xss);                        // => [1:2:3:4:5:6:7:8:9:[]]

(static) concatMap(f, xs) → {List}

Map a function that takes a value and returns a List over a List of values and concatenate the resulting list. In the future, should work on all Foldable types.
Haskell> concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

Parameters:
Name Type Description
f function

The function to map

xs List

The List to map over

Source:
Returns:

The List of results of mapping f over xs, concatenated

Type
List
Example
const f = x => list(x * 3);
const lst = list(1,2,3);    // [1:2:3:[]]
map(f, lst);                // => [[3:[]]:[6:[]]:[9:[]]:[]]
concatMap(f, lst);          // => [3:6:9:[]]