I got a list of lists in racket and have to transpose them.
(: transpose ((list-of(list-of %a)) -> (list-of (list-of %a))))
(check-expect (transpose (list (list 1 2 3)
(list 4 5 6)))
(list (list 1 4)
(list 2 5)
(list 3 6)))
(define transpose
(lambda (xs)
(cond
((empty? xs)empty)
((pair? xs)(make-pair (make-pair (first(first xs)) (make-pair (first(first(rest xs)))empty)) (transpose (rest(rest xs))))))))
That's my code at the moment. I think the problem is in the recursive call (correct me if I'm wrong please).
The actual outcome is (list (list 1 4))
. The rest seems kinda ignored.
It would really help me, if somebody knows the problem, or has a tip.
apply(zip, [['a', 'b'], ['c', 'd'], ['e', 'f']])
. I know you didn't ask about Python, but I'm offering this as general knowledge. Python has lots of lispy bits bodged together in 'junkyard-wars' style. It's also MUCH easier to share with friends than is any real lisp. – Vilma