*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 | |

3 | data Expr = Val Int | Add Expr Expr |

4 | |

5 | folde :: (Int -> a) -> (a -> a -> a) -> Expr -> a |

6 | folde f g (Val x) = f x |

7 | folde f g (Add x y) = g (folde f g x) (folde f g y) |