# 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

- $\displaystyle \operatorname{partition}(\left[ 1, 2, 3, 4 \right], 2) = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$

  `partition([1, 2, 3, 4], 2)`

  In the solver, `partition([1, 2, 3, 4], 2)` gives `[[1, 2], [3, 4]]`.

  [Open in the solver](https://hilberon.com/?q=partition%28%5B1%2C%202%2C%203%2C%204%5D%2C%202%29)

## Related functions

- [position](https://hilberon.com/library/position)

  Where a value occurs in a list, as a list of positions.
- [part](https://hilberon.com/library/part)

  Read part of a list by position, counting from 1; also written list\[i\].
- [prepend](https://hilberon.com/library/prepend)

  A list with an element added at the start.
- [nest_list](https://hilberon.com/library/nest_list)

  The steps of nest: the value after each application, starting from the first.
- [range](https://hilberon.com/library/range)

  The whole numbers in a range, as a list.
- [nest](https://hilberon.com/library/nest)

  Apply a function again and again to a value.

---
Source: https://hilberon.com/library/partition
