Matrix addition in Scheme
Posted
by user285012
on Stack Overflow
See other posts from Stack Overflow
or by user285012
Published on 2010-03-03T05:58:12Z
Indexed on
2010/06/08
2:12 UTC
Read the original article
Hit count: 554
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)))))
© Stack Overflow or respective owner