diff options
author | pkoppstein <pkoppstein@gmail.com> | 2017-02-26 02:35:49 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2017-04-15 16:45:00 -0500 |
commit | 4b4cf789e00f1139940f5f7cd2f2ddafaff3d89e (patch) | |
tree | d24f6888b19a8eda7efcc510bd7eef4c61be2a3d /src | |
parent | 76b1fc18f1d6cd574aa142f92a9a2ee6f7b6d1c6 (diff) |
def isempty(g) # Testing 'isempty(empty)' at line number 1364
Diffstat (limited to 'src')
-rw-r--r-- | src/builtin.jq | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/builtin.jq b/src/builtin.jq index 1432d993..1a5d1e94 100644 --- a/src/builtin.jq +++ b/src/builtin.jq @@ -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; |