add skip/2 as the counterpart to limit/2 (#3181)
I also changed the behavior of limit/2 with negative count to emit an error, like nth/2 does. Also, I redefined nth/2 using skip/2 to minimize the impact of growth of builtin filters.
This commit is contained in:
1 parent
860af44fee
commit
1bebd23aad
5 files changed
+70
-13
No files matched your search
@@ -3037,16 +3037,26 @@ sections:
|
||||
input: '[1,2,3]'
|
||||
output: ['false']
|
||||
|
||||
- title: "`limit(n; exp)`"
|
||||
- title: "`limit(n; expr)`"
|
||||
body: |
|
||||
|
||||
The `limit` function extracts up to `n` outputs from `exp`.
|
||||
The `limit` function extracts up to `n` outputs from `expr`.
|
||||
|
||||
examples:
|
||||
- program: '[limit(3;.[])]'
|
||||
- program: '[limit(3; .[])]'
|
||||
input: '[0,1,2,3,4,5,6,7,8,9]'
|
||||
output: ['[0,1,2]']
|
||||
|
||||
- title: "`skip(n; expr)`"
|
||||
body: |
|
||||
|
||||
The `skip` function skips the first `n` outputs from `expr`.
|
||||
|
||||
examples:
|
||||
- program: '[skip(3; .[])]'
|
||||
input: '[0,1,2,3,4,5,6,7,8,9]'
|
||||
output: ['[3,4,5,6,7,8,9]']
|
||||
|
||||
- title: "`first(expr)`, `last(expr)`, `nth(n; expr)`"
|
||||
body: |
|
||||
|
||||
|
||||
Reference in new issue
Block a user