Apply TCO to recurse/1, add recurse/2; tweak docs
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
This commit is contained in:
1 parent
a2f99d43c3
commit
f8fed0f0bc
2 files changed
+35
-7
No files matched your search
@@ -928,9 +928,13 @@ static const char* const jq_builtins[] = {
|
||||
"def del(f): delpaths([path(f)]);",
|
||||
"def _assign(paths; value): value as $v | reduce path(paths) as $p (.; setpath($p; $v));",
|
||||
"def _modify(paths; update): reduce path(paths) as $p (.; setpath($p; getpath($p) | update));",
|
||||
"def recurse(f): ., (f | select(. != null) | recurse(f));",
|
||||
|
||||
// recurse
|
||||
"def recurse(f): def r: ., (f | select(. != null) | r); r;",
|
||||
"def recurse(f; cond): def r: ., (f | select(cond) | r); r;",
|
||||
"def recurse: recurse(.[]?);",
|
||||
"def recurse_down: recurse;",
|
||||
|
||||
"def to_entries: [keys[] as $k | {key: $k, value: .[$k]}];",
|
||||
"def from_entries: map({(.key): .value}) | add | .//={};",
|
||||
"def with_entries(f): to_entries | map(f) | from_entries;",
|
||||
|
||||
Reference in new issue
Block a user