Fix nth/2 to emit empty on index out of range

This commit is contained in:
itchyny authored and Nico Williams committed 2023-07-08 23:13:15 -05:00
1 parent e2bc8de8bb
commit d8072564c2
3 files changed
+11 -7

No files matched your search

+2 -4
View File
@@ -2832,10 +2832,8 @@ sections:
The `first(expr)` and `last(expr)` functions extract the first
and last values from `expr`, respectively.
The `nth(n; expr)` function extracts the nth value output by
`expr`. This can be defined as `def nth(n; expr):
last(limit(n + 1; expr));`. Note that `nth(n; expr)` doesn't
support negative values of `n`.
The `nth(n; expr)` function extracts the nth value output by `expr`.
Note that `nth(n; expr)` doesn't support negative values of `n`.
examples:
- program: '[first(range(.)), last(range(.)), nth(./2; range(.))]'