I'm trying to write a matrix multiplication function in scheme for a school assignment, but I'm not allowed to use functions we haven't talked about yet, such as map and lambda (outside of defining function parameters). I've already written a function that can multiply a vector by a matrix and a function that can take the dot product of two vectors. For simplicity's sake I'm allowed to assume that the inputs will be valid.
So, the function would take two matrices as parameters. I know the row vectors would be the elements of the first matrix, but how do I get at the columns of the second matrix?
Here's my vector multiplication function:
(define vectormult
(lambda (vec mat)
(cond
((null? mat) vec)
(else (cons (dotproduct vec (car mat)) (vectormult vec (cdr mat)))))))
Here's my dot product function:
(define dotproduct
(lambda(l1 l2)
(cond
((null? l1) 0)
((null? l2) 0)
(else (+ (* (car l1) (car l2)) (dotproduct (cdr l1) (cdr l2)))))))
So how do I iterate through both matrices using recursion?