No title

Anonymous Coward 2018-03-06 20:11:22.968904 UTC

1-- Using folde , define a function eval :: Expr -> Int that evaluates an expression to an integer value, and a function size :: Expr -> Int that calculates the number of values in an expression.
2
3data Expr = Val Int | Add Expr Expr
4
5folde :: (Int -> a) -> (a -> a -> a) -> Expr -> a
6folde f g (Val x) = f x
7folde f g (Add x y) = g (folde f g x) (folde f g y)