Summary: First name Last name Matriculation number
1
Exercise 1 (2+2+2 points)
The following data structure represents binary trees only containing values at the leaves:
data Tree a = Node (Tree a) (Tree a)  Leaf a
Consider the tree t of integers on the righthand
side. The representation of t as an object of type
Tree Int in Haskell would be:
Node (Node (Leaf 1) (Leaf 2)) (Leaf 3)
·
bbbbbbbb
ÑÑÑÑÑÑÑÑ
·
````````
ÒÒÒÒÒÒÒÒ 3
1 2
Implement the following functions in Haskell.
(a) The function foldTree of type (a > a > a) > (b > a) > Tree b > a works as
follows: foldTree n l t replaces all occurrences of the constructor Node in the tree t
by n and it replaces all occurrences of the constructor Leaf in t by l. So for the tree
