I’m 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 the list and cdr gives the tail)
and instead of getting the answer above, I keep reaching wrong answers.
Can anyone help me in understanding this … give me a step or a way to solve it step by step?
Try to do it step by step:
car yields the first element of a list