partition function
A list split into blocks of a given length.
How to write it
partition(list, n)
- list
- The list. Takes a list.
- n
- The length of a block. Takes a whole number.
Examples
partition([1, 2, 3, 4], 2)In the solver,
Open in the solverpartition([1, 2, 3, 4], 2)gives[[1, 2], [3, 4]].
Related functions
- position
Where a value occurs in a list, as a list of positions.
- part
Read part of a list by position, counting from 1; also written list[i].
- prepend
A list with an element added at the start.
- nest_list
The steps of nest: the value after each application, starting from the first.
- range
The whole numbers in a range, as a list.
- nest
Apply a function again and again to a value.