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

Prev:<matrix> ( m n element -- matrix )
Next:<matrix-by-indices> ( ... m n quot: ( ... m' n' -- ... elt ) -- ... matrix )


Vocabulary
math.matrices

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


Outputs
matrixa matrix


Word description
Creates a matrix of size m x n using elements given by quot, a quotation called to create each element.

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

m n [ foo ] <matrix-by>


Examples
USING: math.matrices prettyprint ; 4 5 [ 5 ] <matrix-by> .
{ { 5 5 5 5 5 } { 5 5 5 5 5 } { 5 5 5 5 5 } { 5 5 5 5 5 } }


Definition


: <matrix-by>
( ... m n quot: ( ... -- ... elt ) -- ... matrix )
[ replicate ] 2curry replicate ; inline