# prepend 函数

在开头添加一个元素后的列表。

## 怎么写

### prepend(list, x)

**list**

列表。接受一个列表。

**x**

要添加的元素。接受一个表达式。

## 示例

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

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

  在求解器中，`prepend([1, 2], 0)` 的结果是 `[0, 1, 2]`。

  [在求解器中打开](https://zh.hilberon.com/?q=prepend%28%5B1%2C%202%5D%2C%200%29)

## 相关函数

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

  某个范围内的整数，以列表形式给出。
- [position](https://zh.hilberon.com/library/position)

  某个值在列表中出现的位置，以位置列表表示。
- [replace_part](https://zh.hilberon.com/library/replace_part)

  把某个位置上的部分替换后的列表；写作 position -> value。
- [partition](https://zh.hilberon.com/library/partition)

  将列表按给定长度拆分为若干块。
- [rest](https://zh.hilberon.com/library/rest)

  去掉第一个元素后的列表。
- [part](https://zh.hilberon.com/library/part)

  按位置（从 1 开始计数）读取列表的一部分；也可写作 list\[i\]。

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