car and cdr in scheme is driving me crazy ...
- by kristian Roger
Hi Im facing a probem with the car and cdr functions
for example:
first I defined a list caled 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 rule (the car gives the head of list and cdr gives the tail)
and instead of getting the answer above I keep reaching wronge answers
can any one help me in understanding this ... give me step or a way to solve it step by step
thanx in advance Im really sick of scheme language.