Finding greatest product of two lists, but keep getting #unspecific
- by user1787030
(define (greatest-product lst1 lst2)
(define (helper lst addtimes total toacc)
(cond ((null? lst) '())
((= (countatoms lst) 1) (display total))
((= addtimes (cadr lst)) (helper (cdr lst) 1 total total))
(else (helper lst (+ 1 addtimes) (+ toacc total) toacc))))
(cond ((> (helper lst1 0 0 (car lst1)) (helper lst2 0 0 (car lst2))) (helper lst1 0 0 (car lst1)))
((< (helper lst1 0 0 (car lst1)) (helper lst2 0 0 (car lst2))) (helper lst2 0 0 (car lst2)))
((= (helper lst1 0 0 (car lst1)) (helper lst2 0 0 (car lst2))) (display 'equal))))
Scheme keeps returning back that it cannot perform the procedure with #unspecific
Im running it with
(display (greatest-product '(1 2 3) '(4 5 6)))
(display (greatest-product '(1 2 3) '(1 2 3)))
(display (greatest-product '(1 2 3) '()))
what is wrong with it? the problem seems to be occurring