Suppose I have a simple symbol:
> '+
+
Is there any way I can apply that symbol as a procedure:
> ((do-something-with '+) 1 2)
3
So that '+
is evaluated to the procedure +
?
Suppose I have a simple symbol:
> '+
+
Is there any way I can apply that symbol as a procedure:
> ((do-something-with '+) 1 2)
3
So that '+
is evaluated to the procedure +
?
Lucas's answer is great. For untrusted input you can make a white list of allowed symbols/operators.
Newbie too so hope I've understood your question correctly...
Functions are first class objects in scheme so you don't need eval:
HTH
Update: Ignore this and see the comments!
I'm not 100% sure, but would:
work? I'm not sure if you need to specify the environment, or even if that works - I'm a Scheme noob. :)