29 May
                
                    2009
                
            
            
                29 May
                
                '09
                
            
            
            
        
    
                12:17 p.m.
            
        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