You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To Reproduce
In the first example: 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)'
Redundant operation: else . produces an extra value beyond upto, then | select((by > 0 and . < upto) or (by < 0 and . > upto)) filters it.
Should result in empty when init == upto.
Expected behavior
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)'
Environment (please complete the following information):
/
Additional context
/
The text was updated successfully, but these errors were encountered:
Describe the bug
jq 1.7 Manual / Generators and iterators
To Reproduce
In the first example:
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)'
else .
produces an extra value beyondupto
, then| select((by > 0 and . < upto) or (by < 0 and . > upto))
filters it.empty
wheninit == upto
.Expected behavior
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)'
Environment (please complete the following information):
/
Additional context
/
The text was updated successfully, but these errors were encountered: