<matrix-by-indices> ( ... m n quot: ( ... m' n' -- ... elt ) -- ... matrix )
Matrix operations

Prev:<matrix-by> ( ... m n quot: ( ... -- ... elt ) -- ... matrix )
Next:<zero-matrix> ( m n -- matrix )


Vocabulary
math.matrices

Inputs
man integer
nan integer
quota quotation with stack effect ( ... m' n' -- ... elt )


Outputs
matrixa matrix


Word description
Creates an m x n matrix using elements given by quot . This word differs from <matrix-by> in that the indices are placed on the stack (in the same order) before quot runs. The output of the quotation will be the element at the given position in the matrix.

Notes
The following are equivalent:
m n [ 2drop foo ] <matrix-by-indices>

m n [ foo ] <matrix-by>


Examples
USING: math math.matrices prettyprint ; 3 4 [ * ] <matrix-by-indices> .
{ { 0 0 0 0 } { 0 1 2 3 } { 0 2 4 6 } }


Definition


: <matrix-by-indices>
( ... m n quot: ( ... m' n' -- ... elt ) -- ... matrix )
[ [ <iota> ] bi@ ] dip cartesian-map ; inline