position function
Where a value occurs in a list, as a list of positions.
How to write it
position(list, x)
- list
- The list. Takes a list.
- x
- The value to look for. Takes an expression.
Examples
position([5, 6, 7], 6)In the solver,
Open in the solverposition([5, 6, 7], 6)gives[[2]].
Related functions
- prepend
A list with an element added at the start.
- partition
A list split into blocks of a given length.
- range
The whole numbers in a range, as a list.
- part
Read part of a list by position, counting from 1; also written list[i].
- replace_part
A list with the part at a position replaced; write position -> value.
- nest_list
The steps of nest: the value after each application, starting from the first.