The index must be non-negative integer
and added instructions on how to get the last value in the list.
This commit is contained in:
parent
818029826b
commit
6408533fca
|
@ -19,7 +19,7 @@ element(list, index)
|
||||||
```
|
```
|
||||||
|
|
||||||
The index is zero-based. This function produces an error if used with an
|
The index is zero-based. This function produces an error if used with an
|
||||||
empty list.
|
empty list. The index must be non-negative integer.
|
||||||
|
|
||||||
Use the built-in index syntax `list[index]` in most cases. Use this function
|
Use the built-in index syntax `list[index]` in most cases. Use this function
|
||||||
only for the special additional "wrap-around" behavior described below.
|
only for the special additional "wrap-around" behavior described below.
|
||||||
|
@ -39,6 +39,15 @@ If the given index is greater than the length of the list then the index is
|
||||||
a
|
a
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To get the last element from the list use [`length`](./length.html) to find
|
||||||
|
the size of the list (minus 1 as the list is zero-based) and then pick the
|
||||||
|
last element:
|
||||||
|
|
||||||
|
```
|
||||||
|
> element(["a", "b", "c"], length(["a", "b", "c"])-1)
|
||||||
|
c
|
||||||
|
```
|
||||||
|
|
||||||
## Related Functions
|
## Related Functions
|
||||||
|
|
||||||
* [`index`](./index.html) finds the index for a particular element value.
|
* [`index`](./index.html) finds the index for a particular element value.
|
||||||
|
|
Loading…
Reference in New Issue