# replace_part function

A list with the part at a position replaced; write position -> value.

## How to write it

### replace_part(list, rule)

**list**

The list. Takes a list.

**rule**

The position and the new value, written position -> value. Takes a rule.

## Examples

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

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

  In the solver, `replace_part([1, 2, 3], 2 -> 9)` gives `[1, 9, 3]`.

  [Open in the solver](https://hilberon.com/?q=replace_part%28%5B1%2C%202%2C%203%5D%2C%202%20-%3E%209%29)

## Related functions

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

  Read part of a list by position, counting from 1; also written list\[i\].
- [rest](https://hilberon.com/library/rest)

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

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

  A list in reverse order.
- [prepend](https://hilberon.com/library/prepend)

  A list with an element added at the start.
- [riffle](https://hilberon.com/library/riffle)

  A list with a value put between its elements.

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