@filter
Keep elements of an array for which a helper returns truthy.
Returns: array
Syntax
Section titled “Syntax”@filter(arr fn)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
arr |
array |
Source array |
fn |
helper |
Predicate helper returning bool |
Examples
Section titled “Examples”# Filter positive numbersdef @isPositive "$n: number -> bool" @bool($n > 0)set $nums [-1 2 -3 4]set $pos @filter($nums @isPositive)