Patrick LeBoutillier wrote:
Hi all,
Is it possible with Haskell to call a function whose name is contained
in a String?
Something like:
five = call_func "add" [2, 3]
You could use Data.Map:
call_func = (funcMap !)
where funcMap = fromList [ ("add", add)
, ("sub", sub)
, ("mul", mul)
, ("div", div)]
Or a version using lookup instead of (!) if you aren't sure that the
string will be a valid function name.
- Jake
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe