Matrix addition in Scheme
- by user285012
I am trying to add a matrix and it is not working...
(define (matrix-matrix-add a b)
(map (lambda (row) (row-matrix-add row b))
a))
(define (row-matrix-add row matrix)
(if (null? (car matrix))
'()
(cons (add-m row (map car matrix))
(row-matrix-add row (map cdr matrix)))))
(define (add-m row col)
(if (null? col)
0
(+ (car row)
(car col)
(add-m (cdr row) (cdr col)))))