I'm stuck on the question for Exercise 17.1.2 from HTDP. This is what I've got so far:
(define (cross alist1 alist2)
(cond
[(empty? alist1) empty]
[else (append (list (first alist1)(first alist2))
(cons (first alist1)(list (first (rest alist2))))
(cross (rest alist1) alist2))]))
(cross '(a b c) '(1 2))
;correctly outputs (list 'a 1 'a 2 'b 1 'b 2 'c 1 'c 2)
This works for the test case, but when the second list has more than 2 elements, the function falls apart.
(cross '(a b c) '(1 2 3))
;outputs (list 'a 1 'a 2 'b 1 'b 2 'c 1 'c 2)
The problem seems to be the second line after the append, because it's only cons'ing up to two elements from the second list. How should I go about resolving this? Thanks for any insight. :)