select_index¶
Syntax¶
Parameters¶
list-expression- An expression that evaluates to the list to select from.
test- A true-false expression that is evaluated for each item in the list.
Returns¶
The action returns a list, which may be empty.
Description¶
Selects one or more items from a list and returns their indices.
The first argument specifies a list from which indices are to be selected, while the second argument specifies a true-false expression.
This action returns a list consisting of the positions of all items in the first argument list for which the expression returns true. The special variable _ in the test refers to the list item being evaluated.
Examples¶
Select the indices of the positive numbers from a list:
xlist = list(10, 0, -20, 0.5)
positives_index_list = select_index(x_list, _ > 0)
# positives_index_list = list(0, 3)