]> granicus.if.org Git - jq/commitdiff
Fix #702
authorNicolas Williams <nico@cryptonector.com>
Wed, 18 Feb 2015 16:21:09 +0000 (10:21 -0600)
committerNicolas Williams <nico@cryptonector.com>
Wed, 18 Feb 2015 16:21:21 +0000 (10:21 -0600)
builtin.c
tests/all.test

index a07b97261b985d79d998085bc29b2dfd7830ac36..0c1ee4211be0cf30165c7d5f7aa86d0a5ce184cb 100644 (file)
--- 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;",
index 6f2e18986804c912786633bd8de3543c28face8b..0d3526e9e44f966ee711855b972825c4836d615b 100644 (file)
@@ -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.