[racket] Functions as symbols

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Fri Oct 7 08:58:07 EDT 2011

On Fri, Oct 07, 2011 at 08:53:20AM +0100, Mark Carter wrote:
> 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?

Looking at the replies so far leaves me wondering why no one has 
yet suggested

(apply + '(1 2))

Is there some subtlety I'm missing?

-- hendrik

Posted on the users mailing list.