**Paste:**#363203**Author:**Anonymous Coward**Language:**Haskell**Channel:**-**Created:**2018-03-06 20:11:22 UTC**Revisions:**- 2018-03-06 21:04:07 UTC #363221 (diff): No title (Anonymous Coward)
- 2018-03-06 21:03:48 UTC #363220 (diff): No title (Anonymous Coward)
- 2018-03-06 20:59:47 UTC #363217 (diff): No title (Anonymous Coward)
- 2018-03-06 20:56:29 UTC #363216 (diff): No title (Anonymous Coward)
- 2018-03-06 20:56:19 UTC #363215 (diff): No title (Anonymous Coward)
- 2018-03-06 20:56:03 UTC #363214 (diff): No title (Anonymous Coward)
- 2018-03-06 20:55:07 UTC #363213 (diff): No title (Anonymous Coward)
- 2018-03-06 20:54:11 UTC #363212 (diff): No title (Anonymous Coward)
- 2018-03-06 20:50:14 UTC #363211 (diff): No title (Anonymous Coward)
- 2018-03-06 20:50:05 UTC #363210 (diff): No title (Anonymous Coward)
- 2018-03-06 20:49:37 UTC #363209 (diff): No title (Anonymous Coward)
- 2018-03-06 20:42:57 UTC #363208 (diff): No title (Anonymous Coward)
- 2018-03-06 20:42:28 UTC #363207 (diff): No title (Anonymous Coward)
- 2018-03-06 20:11:22 UTC #363203: No title (Anonymous Coward)

1 2 3 4 5 6 7 8 9 10 | -- 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. data Expr = Val Int | Add Expr Expr folde :: (Int -> a) -> (a -> a -> a) -> Expr -> a folde f g (Val x) = f x folde f g (Add x y) = g (folde f g x) (folde f g y) size :: Expr -> Int size = folde (const 1) (+) |