Home

About

Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network
FAQHELPSITE MAPCONTACT US


  Advanced Search  

 
First name Last name Matriculation number Exercise 1 (2+2+2 points)
 

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 right-hand
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

  

Source: ŃbrahŠm, Erika - Fachgruppe Informatik, Rheinisch Westfšlische Technische Hochschule Aachen (RWTH)

 

Collections: Computer Technologies and Information Sciences