-- Nov 10 In-Class Exercise Thread
(define (ipaux l1 l2 sum)
(if (or (null? l1) (null? l2))
sum ;one or both of the lists is empty, so rest of numbers are treated as 0
(if (and (number? (car l1)) (number? (car l2)))
(ipaux (cdr l1) (cdr l2) (+ sum (* (car l1) (car l2)))) ;both heads are numbers
(ipaux (cdr l1) (cdr l2) sum) ;one or the other is not a number
)
)
)
(define (ip l1 l2) (ipaux l1 l2 0))
<pre>
(define (ipaux l1 l2 sum)
(if (or (null? l1) (null? l2))
sum ;one or both of the lists is empty, so rest of numbers are treated as 0
(if (and (number? (car l1)) (number? (car l2)))
(ipaux (cdr l1) (cdr l2) (+ sum (* (car l1) (car l2)))) ;both heads are numbers
(ipaux (cdr l1) (cdr l2) sum) ;one or the other is not a number
)
)
)
(define (ip l1 l2) (ipaux l1 l2 0))
</pre>