We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e113c67 commit 7fd9e86Copy full SHA for 7fd9e86
src/builtin.jq
@@ -168,13 +168,9 @@ def until(cond; next):
168
if cond then . else (next|_until) end;
169
_until;
170
def limit($n; exp):
171
- if $n < 0 then exp else
172
- label $out |
173
- foreach exp as $item (
174
- [$n, null];
175
- if .[0] < 1 then break $out
176
- else [.[0] -1, $item] end;
177
- if .[0] == 0 then .[1], break $out else .[1] end) end;
+ if $n < 0 then exp
+ else label $out | foreach exp as $item ($n; .-1; $item, if . <= 0 then break $out else empty end)
+ end;
178
def isempty(g): 0 == ((label $go | g | (1, break $go)) // 0);
179
def first(g): label $out | g | ., break $out;
180
def last(g): reduce g as $item (null; $item);
0 commit comments