balanceTree.icl 837 Bytes
Newer Older
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
1
2
3
4
5
6
7
8
9
10
module balanceTree

import StdEnv
import StdHtml

import tree

derive gForm []
derive gUpd []

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
11
Start world  = doHtmlServer MyPage3  world
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
12
13
14
15
//Start world  = doHtml MyPage  world

MyPage hst
# (balancedtree,hst) = mkSelfForm (nFormId "BalancedTree") 
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
16
							(Init (fromListToBalTree [0])) balanceTree hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
17
18
19
20
21
22
23
=	mkHtml "Balanced Tree"
	[ H1 [] "Balanced Tree"
	, BodyTag balancedtree.form
	]  hst

MyPage2 hst
# (sortedlist,hst) = mkSelfForm (nFormId "SortedList") 
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
24
							(Init [0]) sort hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
=	mkHtml "Sorted List"
	[ H1 [] "Sorted List"
	, BodyTag sortedlist.form
	, toHtml (reverse sortedlist.value)
	]  hst

MyPage3 hst
# (treef,hst) = startCircuit mycircuit (Node Leaf 1 Leaf) hst
= mkHtml "Self Balancing Tree"
	[ H1 [] "Self Balancing Tree"
	, toBody treef
	] hst
where
	mycircuit = feedback (edit (nFormId "tree")) (arr  balanceTree)
	
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
40