# prepend function

A list with an element added at the start.

## How to write it

### prepend(list, x)

**list**

The list. Takes a list.

**x**

The element to add. Takes an expression.

## Examples

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

  `prepend([1, 2], 0)`

  In the solver, `prepend([1, 2], 0)` gives `[0, 1, 2]`.

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

## Related functions

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

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

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

  A list with the part at a position replaced; write position -> value.
- [partition](https://hilberon.com/library/partition)

  A list split into blocks of a given length.
- [rest](https://hilberon.com/library/rest)

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

  Read part of a list by position, counting from 1; also written list\[i\].

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