diff options
author | Nicolas Williams <nico@cryptonector.com> | 2017-01-23 17:10:51 -0600 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2017-01-30 14:11:05 -0600 |
commit | e24af3c78e78a3aab05a2800d825d56f1d842b1b (patch) | |
tree | efa76de9069bdbb00703002ca710acae8c3a2a90 /docs | |
parent | e82147bbb859413744ec9591065bf87d2b281ce4 (diff) |
reduce: handle empty updates (fix #1313)
Diffstat (limited to 'docs')
-rw-r--r-- | docs/content/3.manual/manual.yml | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index 4dd9d3ac..94aa2476 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -2413,10 +2413,18 @@ sections: (2 as $item | . + $item) | (1 as $item | . + $item) + If the reduction update expression outputs `empty` (that is, + no values), then the reduction state is left as-is. For + example, `reduce range(4) as $n ({}; if .==2 then empty else + .[$n|tostring] |= $n)` will produce `{"0":0,"1":1,"3":3}`. + examples: - program: 'reduce .[] as $item (0; . + $item)' input: '[10,2,5,3]' output: ['20'] + - program: 'reduce .[] as $n ([]; if $n%2==0 then empty else . + [$n] end)' + input: '[0,1,2,3,4,5]' + output: ['[1,3,5]'] - title: "`limit(n; exp)`" body: | |