change-nth ( ..a i seq quot: ( ..a elt -- ..b newelt ) -- ..b )
Factor handbook » The language » Collections » Sequence operations » Destructive sequence operations

Prev:accumulate*! ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... seq )
Next:remove! ( elt seq -- seq )


Vocabulary
sequences

Inputs
ia non-negative integer
seqa mutable sequence
quota quotation with stack effect ( ..a elt -- ..b newelt )


Outputs
None

Word description
Applies the quotation to the ith element of the sequence, storing the result back into the sequence.

Errors
Throws an error if the sequence is immutable, if the index is out of bounds, or the sequence cannot hold elements of the type output by quot.

Side effects
Modifies seq

See also
change-at, ?change-at, change

Definition


: change-nth
( ..a i seq quot: ( ..a elt -- ..b newelt ) -- ..b )
[ [ nth ] dip call ] 2keepd set-nth-unsafe ; inline