matrix-set-nth ( obj pair matrix -- ) (original) (raw)

Vocabulary
math.matrices

Inputs

Outputs
None

Word description
Set the element in the matrix at the 2D index given by pair to obj. This operation is destructive.

Side effects
Modifies matrix

Notes

This word is the two-dimensional variant of set-nth.
This word is intended for use with "flat" (2-dimensional) matrices.

Errors

bounds-error if the first element of a pair in pairs is greater than the maximum row index in matrix
bounds-error if the second element of a pair in pairs is greater than the maximum column index in matrix
Throws an error if the sequence cannot hold elements of the given type.

Examples
Change the entry at row 1, column 0.

USING: math.matrices kernel prettyprint ; { { 0 1 } { 2 3 } } "a" { 1 0 } pick matrix-set-nth .
{ { 0 1 } { "a" 3 } }

Definition