The problem is the following and it found in http://www.cs.indiana.edu/classes/b551-leak/scheme_practice.html .
Problem definition: Write a function cxr that is a generalization of the car/cdr operators provided in Scheme. cxr should take a string of "a"s and "d"s representing the sequence of car and cdr operations to be performed and return a function capable of performing that sequence.
Thus (cxr "ad") is equivalent to the function cadr.
((cxr "ad") '(i ii iii iv v vi vii)) ==> ii
(define sixth (cxr "addddd"))
(sixth '(i ii iii iv v vi vii)) ==> vi
My attempt: I converted cxr "ad" into a string "cadr" using string-append. [This is easy] .. Now how can I link between "cadr" with cadr ... I tried the string->symbol, but the output is quoted and whence the function is not executed. -- so is there any way of unquoting ?!
The real question: how to solve this problem ?
UPDATE: Thanks all for these answers. They are all correct and I have solved it this way actually before I even post the question. I was mainly looking for a way to actually call caddddr when the input is (cxr adddd) ... Everbody did the same functionality as caddddr but did not actually call cadddr.
That is, how to make functions wit the same naming type as cadr caddr etc.
UPDATE: (I think I found the solution and it is as follows - but as it is told below it does not work for longer d's):
(define cxr
(lambda (ad l)
( (eval (string->symbol (string-append "c" ad "r"))) l)
)
)