7.2 Types, Predicates and Accessors
syntax
(Matrix A)
Examples:
procedure
(row-matrix? arr) → Boolean
arr : (Array A)
procedure
(col-matrix? arr) → Boolean
arr : (Array A)
procedure
(square-matrix? arr) → Boolean
arr : (Array A)
procedure
(matrix-shape M) → (Values Index Index)
M : (Matrix A)
Examples:
> (matrix-shape (row-matrix [1 2 3])) - : (values Integer Integer) [more precisely: (Values Index Index)]
1
3
> (matrix-shape (col-matrix [1 2 3])) - : (values Integer Integer) [more precisely: (Values Index Index)]
3
1
> (matrix-shape (identity-matrix 3)) - : (values Integer Integer) [more precisely: (Values Index Index)]
3
3
procedure
(matrix-num-rows M) → Index
M : (Matrix A)
procedure
(matrix-num-cols M) → Index
M : (Matrix A)
procedure
(square-matrix-size M) → Index
M : (Matrix A)
Examples:
> (square-matrix-size (identity-matrix 3)) - : Integer [more precisely: Index]
3
> (square-matrix-size (row-matrix [1 2 3])) square-matrix-size: contract violation
expected: square-matrix?
given: (array #[#[1 2 3]])