Skip to main content

Iterator: Filter

Run a predicate sub-graph once per element of an input list and keep only the elements whose collected boolean is true. Mirrors JavaScript's Array.prototype.filter.

The auto-created Iterator::Collect expects a Bool on its keep connector to decide whether the current element survives.

Example
Input: [1, 2, 3, 4, 5]
Body: el → el % 2 === 0
Output: [2, 4]

Parameters

This function has no parameters.

Input

ArrayREQUIRED

List to iterate over (Array or JSON array).

Value

Optional value injected into every iteration as value on the entry node.

Output

Array

List of the elements whose predicate returned true, in original order.