From: Nicolas Williams Date: Wed, 18 Feb 2015 16:21:09 +0000 (-0600) Subject: Fix #702 X-Git-Tag: jq-1.5rc2~141 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b8d08177f20352a3c206350465ecd7135fda891;p=jq Fix #702 --- diff --git a/builtin.c b/builtin.c index a07b972..0c1ee42 100644 --- a/builtin.c +++ b/builtin.c @@ -1020,7 +1020,6 @@ static block bind_bytecoded_builtins(block b) { static const char* const jq_builtins[] = { "def error: error(.);", "def map(f): [.[] | f];", - "def map_values(f): .[] |= f;", "def select(f): if f then . else empty end;", "def sort_by(f): _sort_by_impl(map([f]));", "def group_by(f): _group_by_impl(map([f]));", @@ -1033,6 +1032,7 @@ 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 map_values(f): .[] |= f;", // recurse "def recurse(f): def r: ., (f | select(. != null) | r); r;", diff --git a/tests/all.test b/tests/all.test index 6f2e189..0d3526e 100644 --- a/tests/all.test +++ b/tests/all.test @@ -503,6 +503,10 @@ map(add) [[], [1,2,3], ["a","b","c"], [[3],[4,5],[6]], [{"a":1}, {"b":2}, {"a":3}]] [null, 6, "abc", [3,4,5,6], {"a":3, "b": 2}] +map_values(.+1) +[0,1,2] +[1,2,3] + # # User-defined functions # Oh god.