select¶
Syntax¶
select(<list-or-table-or-list_table>, <expression>)
select(<list-expression>, <index-list-expression>)
Parameters¶
list-or-table-or-list_table- An expression that evaluates to a list, table, or list_table to select from.
expression- An expression that evaluates to a number. This is used as an index/single-valued key for the list.
index-list-expression- An expression that evaluates to a list representing the positions of the items to select (the first item has position
0).
Returns¶
The first form returns the selected list item.
The second form returns a list of items, which may be empty.
Description¶
Selects one or more items from a list. The select() action has two forms.
In both forms, the form argument is a list-expression that evaluates to a list.
In the first form, the expression is evaluated to produce an index, and the
action returns the item from the list with the selected index.
Note
If the expression has decimal digits, they will be truncated.
In the second form, the second argument evaluates to a list of index values, and the action returns a list consisting of the items in the first argument list with the selected indices.
It is a run-time error if an index evaluates to a negative value or a value greater than the size of the list.
Examples¶
Select the value 2 from the list expression list(1,2,3):
This example returns 0 since there is no value at position 3:
Select the first member of the given household: