stitch ( m -- m' ) (original) (raw)

stitch ( m -- m' )
Matrix operations

Prev: column-map ( matrix quot: ( ... col -- ... col' ) -- matrix' )
Next: main-diagonal ( matrix -- seq )

Vocabulary
math.matrices

Inputs

m a matrix

Outputs

m' a matrix

Word description
Folds an n>2-dimensional matrix onto itself.

Examples

USING: math.matrices prettyprint ; { { { 0 5 } { 6 7 } { 0 15 } { 18 21 } } { { 0 10 } { 12 14 } { 0 20 } { 24 28 } } } stitch .
{ { 0 5 0 10 } { 6 7 12 14 } { 0 15 0 20 } { 18 21 24 28 } }

Definition

USING: sequences ;

IN: math.matrices

: stitch ( m -- m' ) [ ] [ [ append ] 2map ] map-reduce ;