Hi
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!
John