# flatten function

Nested lists flattened into one list.

## How to write it

### flatten(list)

**list**

A list of lists. Takes a list.

## Examples

- $\displaystyle \operatorname{flatten}(\left[ \left[ 1, 2 \right], \left[ 3 \right] \right]) = \left[ 1, 2, 3 \right]$

  `flatten([[1, 2], [3]])`

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

  [Open in the solver](https://hilberon.com/?q=flatten%28%5B%5B1%2C%202%5D%2C%20%5B3%5D%5D%29)

## Related functions

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

  Combine the elements of a list from the left with a function, starting from a value.
- [first](https://hilberon.com/library/first)

  The first element of a list.
- [fold_list](https://hilberon.com/library/fold_list)

  The steps of fold: every partial result, starting from the first value.
- [drop](https://hilberon.com/library/drop)

  A list without its first elements.
- [head](https://hilberon.com/library/head)

  The head of an expression: the name of the function it is a call of.
- [dimensions](https://hilberon.com/library/dimensions)

  The size of a list or a matrix, level by level.

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