filterList (Function)

Signature: filterList(list: List<t0>, predicate: (t0) -> bool) -> List<t0>

Description: Returns a new list keeping the elements that satisfy a predicate, in index order.

Parameters

  • list (List): The list
  • predicate ((t0) -> bool): The predicate that returns true for elements to keep

Returns: List

Example

filterList([1, 2, 3, 4], fn(n) => n % 2 == 0)  // [2, 4]
filterList ([1, 2, 3, 4], \n => n % 2 == 0)  // [2, 4]