balanceTree.icl 1.34 KB
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 []

11
12
13
14
derive gForm 	Record
derive gUpd 	Record
derive gParse 	Record
derive gPrint 	Record
15
derive gerda	Record
16

17
18
//Start world  = doHtmlSubServer (4,1,1,"tree") MyPage5  world
Start world  = doHtmlServer MyPage4  world
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
19

20
:: Record = {name :: String, address :: TextArea, zipcode :: Int}
21

22
myrecord :: TextArea
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
23
myrecord = createDefault
24

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
25
	
26
MyPage4 hst
27
28
# (myrecord,hst) = mkEditForm (Init,nFormId "bla" myrecord <@ Submit)  hst
//# (myrecord,hst) = vertlistFormButs 5 True (Init,nFormId "bla" myrecord <@ Submit)  hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
29
30
=	mkHtml "Example"
	[ H1 [] ""
31
32
33
	, BodyTag myrecord.form
	]  hst

34
myBalancedTree 	= pDFormId "BalancedTree" 	(fromListToBalTree [0])
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
35
36
mySortedList	= nFormId "SortedList"  	[0]

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
37
MyPage hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
38
# (balancedtree,hst) = mkSelfForm (initID myBalancedTree) balanceTree hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
39
40
41
42
43
44
=	mkHtml "Balanced Tree"
	[ H1 [] "Balanced Tree"
	, BodyTag balancedtree.form
	]  hst

MyPage2 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
45
# (sortedlist,hst) = mkSelfForm (initID mySortedList) sort hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
46
47
48
49
50
51
52
=	mkHtml "Sorted List"
	[ H1 [] "Sorted List"
	, BodyTag sortedlist.form
	, toHtml (reverse sortedlist.value)
	]  hst

MyPage3 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
53
# (treef,hst) = startCircuit mycircuit (Node Leaf 112 Leaf) hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
54
55
56
57
58
= mkHtml "Self Balancing Tree"
	[ H1 [] "Self Balancing Tree"
	, toBody treef
	] hst
where
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
59
	mycircuit = feedback (edit myBalancedTree) (arr  balanceTree)
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
60
	
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
61