diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-16 15:07:53 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-16 15:07:53 +0100 |
commit | bc42812715fb56e72717bf18809dd9ba59771b3a (patch) | |
tree | c7d3ac872afa5623cf9eae54c55c367b77e94aea /builtin.c | |
parent | 8fbee891b305180bdce956fde177604782c3cdc0 (diff) |
Remove the insane "fold" operation, replace with saner "reduce".
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -554,10 +554,10 @@ static const char* const jq_builtins[] = { "def unique: group_by(.) | map(.[0]);", "def max_by(f): _max_by_impl(map([f]));", "def min_by(f): _min_by_impl(map([f]));", - "def add: fold null as $sum (.[] | $sum + .);", + "def add: reduce .[] as $x (null; . + $x);", "def del(f): delpaths([path(f)]);", - "def _assign(paths; value): value as $v | fold . as $obj (path(paths) as $p | $obj | setpath($p; $v));", - "def _modify(paths; update): fold . as $obj (path(paths) as $p | $obj | setpath($p; getpath($p) | update));", + "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));", "def to_entries: [keys[] as $k | {key: $k, value: .[$k]}];", "def from_entries: map({(.key): .value}) | add;", |