Talk:Haskell Quiz/Bytecode Compiler/Solution Justin Bailey
eval (Statement op left right)
| op == Mult = eval left * eval right
| op == Minus = eval left - eval right
| op == Plus = eval left + eval right
| op == Div = eval left `div` eval right
| op == Pow = eval left ^ eval right
| op == Mod = eval left `mod` eval right
Maybe better written as:
eval (Statement op left right) = eval left `f` eval right
where f Mult = (*)
f Minus = (-)
f Plus = (+)
f Div = div
f Pow = (^)
f Mod = mod