I need to write a recursive function in Scheme which takes a list of atoms and reverses it in linear time. I am only allowed to use define, lambda, cons, car, cdr, cond, let, and null? . Here is what I have so far:
(define reverse
(lambda (lat)
(cond
((null? lat) lat)
(else (cons (reverse (cdr lat)) (cons (car lat) '()))))))
So when I call the function:
(reverse '(a b c d))
I get the following output:
'(() (((() 4) 3) 2) 1)
Any help would be very much appreciated.