Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

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)=(1234)\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
  • 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.