From ffa2832e3345c7a405dfaabf1deb923c07d2627c Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Mon, 23 Mar 2015 14:57:35 -0500 Subject: Drop name-less label/break for now See #734 and #658. --- builtin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 03c90814..462307dd 100644 --- a/builtin.c +++ b/builtin.c @@ -1253,16 +1253,16 @@ static const char* const jq_builtins[] = { "def paths: path(recurse(if (type|. == \"array\" or . == \"object\") then .[] else empty end))|select(length > 0);", "def paths(node_filter): . as $dot|paths|select(. as $p|$dot|getpath($p)|node_filter);", "def any(generator; condition):" - " [label | foreach generator as $i" + " [label $out | foreach generator as $i" " (false;" - " if . then break elif $i | condition then true else . end;" + " if . then break $out elif $i | condition then true else . end;" " if . then . else empty end)] | length == 1;", "def any(condition): any(.[]; condition);", "def any: any(.);", "def all(generator; condition): " - " [label | foreach generator as $i" + " [label $out | foreach generator as $i" " (true;" - " if .|not then break elif $i | condition then . else false end;" + " if .|not then break $out elif $i | condition then . else false end;" " if .|not then . else empty end)] | length == 0;", "def all(condition): all(.[]; condition);", "def all: all(.);", @@ -1373,8 +1373,8 @@ static const char* const jq_builtins[] = { " def _until: " " if cond then . else (next|_until) end;" " _until;", - "def limit($n; exp): if $n < 0 then exp else label | foreach exp as $item ([$n, null]; if .[0] < 1 then break else [.[0] -1, $item] end; .[1]) end;", - "def first(g): label | foreach g as $item ([false, null]; if .[0]==true then break else [true, $item] end; .[1]);", + "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 first(g): label $out | foreach g as $item ([false, null]; if .[0]==true then break $out else [true, $item] end; .[1]);", "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;", "def first: .[0];", -- cgit v1.2.3