601efccaddf465e60ee29655145c52fbac63d321
[fp1415.git] / week7 / camil / BinTree.icl
1 implementation module BinTree
2
3 import StdEnv
4
5 :: Tree a = Node a (Tree a) (Tree a) | Leaf
6
7 t0 :: Tree Int
8 t0 = Leaf
9 t1 :: Tree Int
10 t1 = Node 4 t0 t0
11 t2 :: Tree Int
12 t2 = Node 2 t0 t1
13 t3 :: Tree Int
14 t3 = Node 5 t2 t0
15 t4 :: Tree Int
16 t4 = Node 5 t2 t2
17 t5 :: Tree Int
18 t5 = Node 1 Leaf (Node 2 Leaf (Node 3 Leaf (Node 4 Leaf Leaf)))
19 t6 :: Tree Int
20 t6 = Node 1 (Node 2 (Node 3 (Node 4 Leaf Leaf) Leaf) Leaf) Leaf
21 t7 :: Tree Int
22 t7 = Node 4 (Node 1 Leaf Leaf) (Node 5 (Node 2 Leaf Leaf) Leaf)
23
24 // 2.
25 //nodes :: // meest algemene type
26 //nodes ...
27
28 //Start = map nodes [t0,t1,t2,t3,t4,t5,t6,t7]
29
30 //leaves :: // meest algemene type
31 //leaves ...
32
33 //Start = map leaves [t0,t1,t2,t3,t4,t5,t6,t7]
34
35 //diepte :: // meest algemene type
36 //diepte ...
37
38 //Start = map diepte [t0,t1,t2,t3,t4,t5,t6,t7]