Fix redundant subexpression in Generators and iterators example in doc (#3239)
This commit is contained in:
1 parent
31dac287cc
commit
da28628edd
3 files changed
+4
-5
No files matched your search
@@ -3223,9 +3223,8 @@ sections:
|
||||
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));
|
||||
else empty end;
|
||||
if init == upto then empty elif by == 0 then init else init|_range end;
|
||||
range(0; 10; 3)'
|
||||
input: 'null'
|
||||
output: ['0', '3', '6', '9']
|
||||
|
||||
Generated
+1
-1
@@ -3644,7 +3644,7 @@ All jq functions can be generators just by using builtin generators\. It is also
|
||||
.
|
||||
.nf
|
||||
|
||||
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)\'
|
||||
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)\'
|
||||
null
|
||||
=> 0, 3, 6, 9
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -927,7 +927,7 @@ foreach .[] as $item (0; . + 1; {index: ., $item})
|
||||
{"index":2,"item":"bar"}
|
||||
{"index":3,"item":"baz"}
|
||||
|
||||
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)
|
||||
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)
|
||||
null
|
||||
0
|
||||
3
|
||||
|
||||
Reference in new issue
Block a user