"def paths(node_filter): . as $dot|paths|select(. as $p|$dot|getpath($p)|node_filter);",
"def any: reduce .[] as $i (false; . or $i);",
"def all: reduce .[] as $i (true; . and $i);",
+ "def any(condition): reduce .[] as $i (false; . or ($i|condition));",
+ "def all(condition): reduce .[] as $i (true; . and ($i|condition));",
+ "def any(generator; condition): reduce generator as $i (false; . or ($i|condition));",
+ "def all(generator; condition): reduce generator as $i (true; . and ($i|condition));",
"def arrays: select(type == \"array\");",
"def objects: select(type == \"object\");",
"def iterables: arrays, objects;",
input: '[]'
output: ["null"]
- - title: "`any`"
+ - title: "`any`, `any(condition), `any(generator; condition)`"
body: |
The filter `any` takes as input an array of boolean values,
If the input is an empty array, `any` returns `false`.
+ The `any(condition)` form applies the given condition to the
+ elements of the input array.
+
+ The `any(generator; condition)` form applies the given
+ condition to all the outputs of the given generator.
+
examples:
- program: any
input: '[true, false]'
input: '[]'
output: ["false"]
- - title: "`all`"
+ - title: "`all`, `all(condition), `all(generator; condition)`"
body: |
The filter `all` takes as input an array of boolean values,
and produces `true` as output if all of the the elements of
the array are `true`.
+ The `all(condition)` form applies the given condition to the
+ elements of the input array.
+
+ The `all(generator; condition)` form applies the given
+ condition to all the outputs of the given generator.
+
If the input is an empty array, `all` returns `true`.
examples: