filter
for filters
Filter values based on a predicate closure.
Signature
> filter (closure)
Parameters
closure
: Predicate closure
Notes
This command works similar to 'where' but allows reading the predicate closure from a variable. On the other hand, the "row condition" syntax is not supported.
Examples
Filter items of a list according to a condition
> [1 2] | filter {|x| $x > 1}
╭───┬───╮
│ 0 │ 2 │
╰───┴───╯
Filter rows of a table according to a condition
> [{a: 1} {a: 2}] | filter {|x| $x.a > 1}
╭───┬───╮
│ # │ a │
├───┼───┤
│ 0 │ 2 │
╰───┴───╯
Filter rows of a table according to a stored condition
> let cond = {|x| $x.a > 1}; [{a: 1} {a: 2}] | filter $cond
╭───┬───╮
│ # │ a │
├───┼───┤
│ 0 │ 2 │
╰───┴───╯