filter
filters values in a list or dict
(any xs, function p) -> any
Filters a list or dict xs by passing elements to predicate function p.
If p accepts a single argument, p(x) is evaluated. If p accepts two arguments, p(x, i) is evaluated, where i is the index or key of x in xs
Returns a filtered version of xs in which all values for which p returns a value that casts to boolean true are included. All other values are removed.
Returns nil if xs is nil or p is nil.
Parameters
| Name | Type | Description |
|---|---|---|
xs |
list or dict | The list or dict to work with |
p |
function |
A predicate function of the form (any x, long i) -> boolean that returns true if item x at index i should be included in the result. |