[racket] Functions as symbols

From: Mark Carter (mcturra2000 at yahoo.co.uk)
Date: Fri Oct 7 03:53:20 EDT 2011

I would like to treat a symbol as a function, and apply it to some arguments. In other words, if I did something like
(define sym '+)
(apply '+ '(1 2))
I would obtain the answer 3. Is there any way I can do this? The following works, but I'm wondering if it's the best way:
(eval `(apply ,sym '(1 2)))
A more basic question would be: is there any way I can convert from '+ to + - i.e. a symbol to a function?




Posted on the users mailing list.