IN: ... USING: math sequences kernel prettyprint ; : matrix-nth ( n matrix -- elt ) [ first length [ rem ] [ /i ] 2bi ] keep nth nth ; : matrix-length ( matrix -- n ) [ length ] [ first length * ] bi ; ! example { { 3 4 } { 2 1 } { 5 7 } { 3 2 } } dup matrix-length [ swap matrix-nth . ] with each