car and cdr in Scheme are driving me crazy ...
- by kristian Roger
Hi Im facing a problem with the car and cdr functions
for example:
first I defined a list called it x
(define x (a (bc) d ( (ef) g ) ))
so x now is equal to (a (bc) d ( (ef) g ) )
now for example I need to get the g from this list using only car and cdr
(!! noshortcuts as caddr cddr !!) the correct answer is:
(car(cdr(car(cdr(cdr(cdr x))))))
BUT how ? :-( I work according to the rules (the car gives the head of list and cdr gives the tail)
and instead of getting the answer above I keep reaching wrong answers.
Can any one help me in understanding this ... give me step or a way to solve it step by step
Thanks in advance. I'm really sick of Scheme.