# replace_part 函数

把某个位置上的部分替换后的列表；写作 position -> value。

## 怎么写

### replace_part(list, rule)

**list**

列表。接受一个列表。

**rule**

位置和新值，写作 position -> value。接受一条规则。

## 示例

- $\displaystyle \operatorname{replace\_part}(\left[ 1, 2, 3 \right], 2 \to 9) = \left[ 1, 9, 3 \right]$

  `replace_part([1, 2, 3], 2 -> 9)`

  在求解器中，`replace_part([1, 2, 3], 2 -> 9)` 的结果是 `[1, 9, 3]`。

  [在求解器中打开](https://zh.hilberon.com/?q=replace_part%28%5B1%2C%202%2C%203%5D%2C%202%20-%3E%209%29)

## 相关函数

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

  按位置（从 1 开始计数）读取列表的一部分；也可写作 list\[i\]。
- [rest](https://zh.hilberon.com/library/rest)

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

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

  逆序排列的列表。
- [prepend](https://zh.hilberon.com/library/prepend)

  在开头添加一个元素后的列表。
- [riffle](https://zh.hilberon.com/library/riffle)

  在元素之间插入某个值后的列表。

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