Skip to content

Commit a33a1b3

Browse files
committed
Fix redundant subexpression in Generators and iterators example in doc
#3222 `jq 'def range(init; upto; by): def _range: if (by > 0 and . < upto) or (by < 0 and . > upto) then ., ((.+by)|_range) else . end; if by == 0 then init else init|_range end | select((by > 0 and . < upto) or (by < 0 and . > upto)); range(0; 10; 3)'` Can be simplified and corrected to: `jq 'def range(init; upto; by): def _range: if (by > 0 and . < upto) or (by < 0 and . > upto) then ., ((.+by)|_range) else empty end; if init == upto then empty elif by == 0 then init else init|_range end; range(0; 10; 3)'`
1 parent 31dac28 commit a33a1b3

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

docs/content/manual/dev/manual.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -3223,9 +3223,8 @@ sections:
32233223
def _range:
32243224
if (by > 0 and . < upto) or (by < 0 and . > upto)
32253225
then ., ((.+by)|_range)
3226-
else . end;
3227-
if by == 0 then init else init|_range end |
3228-
select((by > 0 and . < upto) or (by < 0 and . > upto));
3226+
else empty end;
3227+
if init == upto then empty elif by==0 then init else init|_range end;
32293228
range(0; 10; 3)'
32303229
input: 'null'
32313230
output: ['0', '3', '6', '9']

jq.1.prebuilt

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/man.test

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)