Filter
Keeps the elements of an array that pass a test.
Node id array/filter
The Filter node calls function once for every element of array and
outputs a new array with only the elements for which it gave true, in their
original order.
The function is a subgraph. To make one that fits,
drag a wire from Filter's
function input onto empty canvas and choose
New function…, or right-click Filter and choose New function….Inputs
| Name | Type | Default | Notes |
|---|---|---|---|
| array | Array<T> | — | generic |
| function | Function(T, number, ...) -> (boolean) | — | generic |
| arguments | X | — | multigenericindependent |
Outputs
| Name | Type | Notes |
|---|---|---|
| array | Array<T> | generic |
Behaviour
- The function has the type
Function(T, number, ...) -> (boolean): it gets the element and its index, and gives true to keep the element. See Functions. - Extra arguments. Values connected to
arguments(a multi input) are passed to every call after the element and index, in slot order, as for Map. - Elements are unchanged. The kept elements are the same values that came in, so the output has the input's element type.
- Each call is separate, with its own random numbers.
Errors
functionmust be connected.- The function must take exactly as many extra parameters as there are
arguments, each of the right type, checked before any call. - If the function fails for any element, Filter fails.
Related nodes
- Map: changes every element instead.
- Slice: keeps elements by position.
- Contains Point: a typical test, to keep the points inside a box.