(define (evenList xs)
(cond
((null? xs) '())
((eq? (cdr xs) '()) '())
(else (cons (cadr xs) (evenList (cddr xs))))))
I'm using this code but it doesn't create the list the way I want it. (evenList (list 1 2 3 4))
evaluates to (cons 2 (cons 4 '()))
in the REPL, but I want it to be like (list 2 4)
.