I have a procedure with no arguments that creates a matrix, but returns nothing, how can i access the matrix?
This is my code:
(define matrix
(lambda (rows columns)
(do ((m (make-vector rows))
(i 0 (+ i 1)))
((= i rows) m)
(vector-set! m i (make-vector columns)))))
(define Mod-matrix!
(lambda (m i j)
(vector-ref (vector-ref m i) j)))
(define (board)
(mk-w (matrix 8 8) 0 0))
(define (mk-b b l c)
(cond ((and (< l 8) (< c 8)) (begin
(Mod-matrix! b l c p)
(mk-b b l (+ c 2))))
((and (>= c 8) (< l 8))(mk-b b (+ l 2) 0))
(else (mk-w b 0 1))))
(define (mk-b b l c)
(cond ((and (< l 8) (< c 8)) (begin
(Mod-matrix! b l c b)
(mk-w ti l (+ c 2))))
((and (>= c 8) (< l 8)) (mk-white b (+ l 2) 0))))
Your mk-w function is not returning the matrix. Try the following:
Note that in each case the last expression in the begin block is the matrix itself, this is because the return value of a begin block is the value of the last expression. In your post, those last expressions returned an undefined value.