balanceTree.icl 1.76 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,0,1,"tree") MyPage5  world
Start world  = doHtmlServer MyPage5  world
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
19

20
MyPage5 hst
21
22
23
# (n1,hst) = mkEditForm (Init,nDFormId "test1" [0]) hst
# (n2,hst) = mkEditForm (Init,pDFormId "test2" [0]) hst
# (n3,hst) = mkEditForm (Set, pDFormId "test2" n1.value) hst
24
25
=	mkHtml "Balanced Tree"
	[ H1 [] "Balanced Tree"
26
27
28
29
30
	, BodyTag n1.form
	, Br
	, toHtml n1.value, Br
	, toHtml n2.value, Br
	, toHtml n3.value, Br
31
	]  hst
32
33
34
35

:: Record = {name :: String, address :: String, zipcode :: Int}

myrecord :: [Record]
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
36
myrecord = createDefault
37

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
38
39
40
41
42
myfun file 
	= if (sfend2 file file) (fwritec 'a' file) (fwritec 'b' file)
	where
		sfend2 n m = sfend n		
	
43
MyPage4 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
44
45
46
47
//# (myrecord,hst) = mkEditForm (Init,nFormId "bla" myrecord)  hst
# (myrecord,hst) = vertlistFormButs 5 True (Init,nFormId "bla" myrecord)  hst
=	mkHtml "Example"
	[ H1 [] ""
48
49
50
	, BodyTag myrecord.form
	]  hst

51
myBalancedTree 	= pDFormId "BalancedTree" 	(fromListToBalTree [0])
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
52
53
mySortedList	= nFormId "SortedList"  	[0]

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
54
MyPage hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
55
# (balancedtree,hst) = mkSelfForm (initID myBalancedTree) balanceTree hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
56
57
58
59
60
61
=	mkHtml "Balanced Tree"
	[ H1 [] "Balanced Tree"
	, BodyTag balancedtree.form
	]  hst

MyPage2 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
62
# (sortedlist,hst) = mkSelfForm (initID mySortedList) sort hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
63
64
65
66
67
68
69
=	mkHtml "Sorted List"
	[ H1 [] "Sorted List"
	, BodyTag sortedlist.form
	, toHtml (reverse sortedlist.value)
	]  hst

MyPage3 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
70
# (treef,hst) = startCircuit mycircuit (Node Leaf 112 Leaf) hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
71
72
73
74
75
= mkHtml "Self Balancing Tree"
	[ H1 [] "Self Balancing Tree"
	, toBody treef
	] hst
where
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
76
	mycircuit = feedback (edit myBalancedTree) (arr  balanceTree)
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
77
	
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
78