Handbook
Glossary
>square-matrix ( m -- subset )
Vocabulary
math
.
matrices
Inputs
m
a
matrix
Outputs
subset
a
square-matrix
Word description
Find only the
square
subset of the input matrix.
Examples
USING: math.matrices prettyprint ; { { 0 2 4 6 } { 1 3 5 7 } } >square-matrix .
{ { 0 2 } { 1 3 } }
Definition
USING:
combinators
kernel
math
sequences
;
IN:
math.matrices
::
>square-matrix
( m -- subset )
m
dimension
first2
:>
( x y )
{
{
[
x y
=
]
[
m
]
}
{
[
x y
<
]
[
x
<iota>
m
cols
transpose
]
}
{
[
x y
>
]
[
y
<iota>
m
rows
]
}
}
cond
;