[Haskell-beginners] if statements

John Moore john.moore54 at gmail.com
Sat Jan 23 12:40:10 EST 2010

   I'm trying to get a if statement to work but not sure if this is the
right approach, what I want to do in simple english is to evaluate  one
expression at a time for example. (3+2)+(4+5) I want it to return 5 + (4+5)
then 5+9.

data Expression = Val Integer
                | Add Expression Expression
                | Subtract Expression Expression
                | Multiply Expression Expression
                | Divide Expression Expression
         deriving Show
evalStep :: Expression ->  Expression
evalStep (Val x)=  (Val x)

evalStep (Add x y) = do

  if x = isDigit
           then if y isDigit
             else evalStep x,y

I thinking about using recursion down a tree left then right but that seems
very complicated.
Any thoughts welcome!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100123/9ac013b2/attachment.html

More information about the Beginners mailing list