balanceTree.icl 1.41 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
Start world  = doHtmlServer MyPage  world
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
18
//Start world  = doHtmlServer testdb  world
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
19

20
21
22
23

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

myrecord :: [Record]
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
24
myrecord = createDefault
25

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
26
27
28
29
30
myfun file 
	= if (sfend2 file file) (fwritec 'a' file) (fwritec 'b' file)
	where
		sfend2 n m = sfend n		
	
31
MyPage4 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
32
33
34
35
//# (myrecord,hst) = mkEditForm (Init,nFormId "bla" myrecord)  hst
# (myrecord,hst) = vertlistFormButs 5 True (Init,nFormId "bla" myrecord)  hst
=	mkHtml "Example"
	[ H1 [] ""
36
37
38
	, BodyTag myrecord.form
	]  hst

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
39
myBalancedTree 	= dbFormId "BalancedTree" 	(fromListToBalTree [0])
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
40
41
mySortedList	= nFormId "SortedList"  	[0]

Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
42
MyPage hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
43
# (balancedtree,hst) = mkSelfForm (initID myBalancedTree) balanceTree hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
44
45
46
47
48
49
=	mkHtml "Balanced Tree"
	[ H1 [] "Balanced Tree"
	, BodyTag balancedtree.form
	]  hst

MyPage2 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
50
# (sortedlist,hst) = mkSelfForm (initID mySortedList) sort hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
51
52
53
54
55
56
57
=	mkHtml "Sorted List"
	[ H1 [] "Sorted List"
	, BodyTag sortedlist.form
	, toHtml (reverse sortedlist.value)
	]  hst

MyPage3 hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
58
# (treef,hst) = startCircuit mycircuit (Node Leaf 112 Leaf) hst
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
59
60
61
62
63
= mkHtml "Self Balancing Tree"
	[ H1 [] "Self Balancing Tree"
	, toBody treef
	] hst
where
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
64
	mycircuit = feedback (edit myBalancedTree) (arr  balanceTree)
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
65
	
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
66