summaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2014-07-06 03:24:29 -0500
committerNicolas Williams <nico@cryptonector.com>2014-07-06 19:40:05 -0500
commit5a863bf0103ccd82edf32cfe4c37ed92783a224d (patch)
tree0667cff3dac30300a92f31d16e8b26950df6d1b3 /builtin.c
parentd0ca11d6652cc8aeb0ea4fc674f427f81dcf1467 (diff)
Add `foreach` and `limit`
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/builtin.c b/builtin.c
index 6af99898..bda2c9ea 100644
--- a/builtin.c
+++ b/builtin.c
@@ -963,6 +963,7 @@ static const char* const jq_builtins[] = {
" def _while: "
" if cond then ., (update | _while) else empty end; "
" _while;",
+ "def limit(n; exp): if n < 0 then exp else foreach exp as $item ([n, null]; if .[0] < 1 then empty else [.[0] -1, $item] end; .[1]) end;",
};
#undef LIBM_DD