Module: list/searching

Methods

(static) filter(f, as) → {List}

Return the List of elements in a List for which a function f returns true.
Haskell> filter :: (a -> Bool) -> [a] -> [a]

Parameters:
Name Type Description
f function

The filter function. Must return a boolean

as List

The List to filter

Source:
Returns:

The filtered List

Type
List
Example
const lst = listRange(1,50);
const f = x => and(odd(x), greaterThan(x, 10));
filter(f, lst); // => [11:13:15:17:19:21:23:25:27:29:31:33:35:37:39:41:43:45:47:49:[]]

(static) lookup(key, assocs) → {Maybe}

Look up a key in an association list. For a list of Tuple objects, returns the second element of the first tuple for which the key matches the first element.
Haskell> lookup :: Eq a => a -> [(a, b)] -> Maybe b

Parameters:
Name Type Description
key *

The key value to lookup

assocs List

A List of Tuple objects

Source:
Returns:

The matching value in a Just or Nothing, otherwise

Type
Maybe
Example
const assocs = list(tuple(1,2), tuple(3,4), tuple(3,3), tuple(4,2));
lookup(3, assocs);                                      // => Just 4
lookup(5, assocs);                                      // => Nothing