filter
Written as filter(argnum flags):options in a transform expression.
| Minimum arguments | 1 |
| Maximum arguments | no limit |
| Default arguments | 1 |
| Argument modes | MULTIPLE_ARRAYS, MULTIPLE_DICTS |
Documentation
Section titled “Documentation”Filter out values failing a check from a list of arguments.
The check is specified as a nested transform, and that transform’s output value determines the input value:
- passes the check, if the transform doesn’t raise any error and output value is truthy, otherwise
- fails the check
These values are considered truthy:
- non-empty text, e.g. ‘hello’
- numbers not equal to zero, e.g. 1, -1, 18
- non-empty array, e.g. [null, 0]
- non-empty dict/map
The nested transform for the check purpose can be omitted, in which case, each value themselves being truthy or not, decides if they are kept or removed.
Features:
- removes all values failing the check from input arguments
- preserves order of remaining values
- works with any number of arguments
- returns a new list containing only values passing the check
| Flag | Letter |
|---|---|
| spread_input | s |
| spread_output | S |
| noncaptive_input | I |
| arg_num_flexible | f |
Examples
Section titled “Examples”Basic filtering
Section titled “Basic filtering”Input args: ["Hello",null,"World",null]Transforms: "filter(*):"Output: ["Hello","World"]Mixed types
Section titled “Mixed types”Input args: [1,null,"text",null,3.14,false,""]Transforms: "filter(*):"Output: [1,"text",3.14]Empty result
Section titled “Empty result”Input args: [null,null,null]Transforms: "filter(*):"Output: []Mixed types and nested transform
Section titled “Mixed types and nested transform”Input args: [1,null,"text",null,3.14,false,""]Transforms: "filter(*):regex:ex"Output: ["text"]Explicit nested pipeline to filter args by keeping those with upper cased form equal to “HELLO”
Section titled “Explicit nested pipeline to filter args by keeping those with upper cased form equal to “HELLO””Input args: ["Hello","World"]Transforms: "filter(*):pipeline(1):[\"cased:upper\", \"HELLO\", \"cmp:=\"]"Output: ["Hello"]Implicit nested pipeline to filter args by keeping those with upper cased form equal to “HELLO”
Section titled “Implicit nested pipeline to filter args by keeping those with upper cased form equal to “HELLO””Input args: ["Hello","World"]Transforms: "filter(*):[\"cased:upper\", \"HELLO\", \"cmp:=\"]"Output: ["Hello"]