length¶
Syntax¶
Parameters¶
list-expression- an expression that evaluates to a list
Returns¶
The length of the list expression.
Description¶
The length() action is used to find the number of elements in a list. Since lists are 0-indexed, the index of the last item in a list of length \(n\) is \(n-1\).
It is an error if the argument to length() is not a list-expression.
Examples¶
Find the length of a list. This returns 3.
Find the value of the last element in a list X. This sets last_item to 5.