[plt-scheme] Converting symbols to procedures?

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sun Aug 6 04:50:25 EDT 2006

Warren Henning skrev:
> Hi,
> 
> I wanted to write some function dispatching code. I wanted to find a
> way to convert strings to procedure references, and of course there's
> string->symbol, but I can't find anything like symbol->procedure.
> 
> Is there any way to convert from symbols to procedures?

Do you know them all before hand? If so use

(define (symbol->procedure s)
   (case s
     ((+) +)
     ((-) -)
     <etc>))

or similar (i.e. a hash-table).

Otherwise loookup namespace-variable-value in the HelpDesk.

-- 
Jens Axel Søgaard



Posted on the users mailing list.