On Sat, 28 Jan 2006, Andrew Savige wrote:

Haskell beginner using GHC.

I have a function to do some simple arithmetic at run time:

myeval :: Int -> Int -> String -> Int
myeval x y "+" = (+) x y
myeval x y "-" = (-) x y
myeval x y "*" = (*) x y
-- ...

Additionally to the other suggestions, I advise using a custom type

  data Op = Add | Sub | Mul

instead of String, if possible.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to