racket/collects/htdp/matrix-sig.ss
Matthias Felleisen 6bb1223ba4 svn: r7983
2007-12-13 04:17:58 +00:00

49 lines
1.5 KiB
Scheme

#lang scheme/signature
;; CONVENTION:
;; [Rectangle X] = [Listof [Listof X]]
;; where all elements of the non-empty list are of equal non-empty length
;; type: [Matrix X]
matrix?
;; is this a matrix?
matrix-n ;; [Matrix X] -> Nat
;; what is n for an n x m Matrix
matrix-m ;; [Matrix X] -> Nat
;; what is m for an n x m Matrix
rectangle->matrix ;; [Rectangle X] -> [Matrix X]
;; create a matrix from a rectangle
matrix->rectangle ;; [Matrix X] -> [Rectangle X]
;; create a rectangle from matrix
;; ----------------------------------------------------------------------------
make-matrix ;; Nat Nat [Listof X] -> [Matrix X]
;; create an initialized n x m matrix from list l
;; NOTE: make-matrix would consume an optional number of entries,
;; if it were like make-vector
build-matrix ;; Nat Nat (Nat Nat -> Number) -> Matrix
;; create a matrix from a function
matrix-ref ;; [Matrix X] Nat Nat -> X
;; retrieve the content of the matrix at (i,j)
matrix-set ;; [Matrix X] Nat Nat X -> [Matrix X]
;; create a new matrix with x at (i,j) and all other places the same
matrix-where? ;; [Matrix X] (X -> Boolean) -> [Listof Posn]
;; (matrix-where? M P) :: list of (make-posn i j) s.t. (P (matrix-ref M i j))
matrix-render ;; [Matrix X] -> [Rectangle String]
;; render the matrix as a rectangle of strings
matrix-minor ;; Matrix Nat Nat -> Matrix
;; create a matrix minor from M at (i,j)
matrix-set! ;; [Matrix X] Nat Nat X -> [Matrix X]
;; set the matrix at (i,j)