Hello, I need help finishing up an unzip function which takes a zipped list and returns a list of two lists. The result I want is as follows. . .
(unzip '((a b)(1 2)))
((a 1)(b 2))
(unzip '((a 1)(b 2)(c 3)))
((a b c)(1 2 3))
(unzip '(unzip '()))
(() ())
I can get my code to work for the null case and with a list containing two lists, but I'm haveing a hard time figuring out how to make it recursive and work for more than 2 lists such as the second example.
(define (unzip l)
(if (null? l) '(() ())
(map list (car l)(car(cdr l)))))
This will work fine for an empty list or two lists, but I'm still new to shcheme and have a hard time setting up the recursive part to work with three or possibly more lists.