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

Matrix operations

Matrix operations

Prev: | matrix-nths ( pairs matrix -- elts ) |

Next: | matrix-set-nths ( obj pairs matrix -- ) |

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

Errors

Examples

Change the entry at row 1, column 0.

Definition

math.matrices

Inputs

obj | an object |

pair | a pair |

matrix | a matrix |

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 } }

{ { 0 1 } { "a" 3 } }

Definition

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.99 x86.64 (2190, heads/master-46c625f8dc, Feb 4 2023 19:37:27)