Methods

filterΒΆ

filter(something:Eachable1, predicate:Any)

Filter something to an Arr (array) of values using predicate.
Source: stdlib.ngs:197

something

Instance of any type that has each(something, callback) implemented.

predicate

Decision function to be called with each item as first argument. When predicate(item) returns true, the item will appear in the resulting array.

Returns

Arr

Example

(1...10).filter(F(num) num % 2 == 0)  # Gives [2,4,6,8,10]
(1...10).filter(X<5)  # Gives [1,2,3,4], predicate called as predicate(item, 5)