Q:

Racket: Recursive List Creation from 2 Lists

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. 

A:

Pretty simple, all we have to do is make a function that will return empty as a base case if either list is empty, otherwise we will cons the (first list1, first list2) to the recursive call. 
(define (zipper list1 list2)
  (cond [(or (empty?  list1)
             (empty?  list2)) empty]
        [else (cons 
               (cons (first list1)
                     (first list2)) ;; List of first elements
               (zipper (rest list1) (rest list2)))]))

