Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

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

  • replace_part⁡([1,2,3],2→9)=[1,9,3]\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
  • part

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

  • rest

    A list without its first element.

  • range

    The whole numbers in a range, as a list.

  • reverse

    A list in reverse order.

  • prepend

    A list with an element added at the start.

  • riffle

    A list with a value put between its elements.