I am supposed to create a function that takes two lists as the arguments and returns a list of pairs from combining the input lists where the pairs are a combination of the elements at the given index.
Example Input:
(zipper '(1 2 3) '(4 9 5 7))
Example Output:
'((1 4) (2 9) (3 5))
If one input list is longer than the other, extra elements of the longer list are ignored. The implementation has to be recursive.
The code I created:
(define (zipper list1 list2)
(if (or (empty? list1) (empty? list2))
'()
(list (list (zipper (rest list1) (rest list2)) ))))
The output:
'((((((((()))))))))
'((((((()))))))
'()
Can someone please help? I've also tried using 'cons' to put the elements together, so am not sure how the elements are getting lost. I'm brand new to Racket. Thanks.