def isempty(g) # Testing 'isempty(empty)' at line number 1364

This commit is contained in:
pkoppstein authored and Nicolas Williams committed 2017-04-15 16:45:00 -05:00
1 parent 76b1fc18f1
commit 4b4cf789e0
4 files changed
+45 -3

No files matched your search

+1
View File
@@ -168,6 +168,7 @@ def until(cond; next):
if cond then . else (next|_until) end;
_until;
def limit($n; exp): if $n < 0 then exp else label $out | foreach exp as $item ([$n, null]; if .[0] < 1 then break $out else [.[0] -1, $item] end; .[1]) end;
def isempty(g): 0 == ((label $go | g | (1, break $go)) // 0);
def first(g): label $out | g | ., break $out;
def last(g): reduce g as $item (null; $item);
def nth($n; g): if $n < 0 then error("nth doesn't support negative indices") else last(limit($n + 1; g)) end;