balanceTree.icl 1.2 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
15
16
17
derive gForm 	Record
derive gUpd 	Record
derive gParse 	Record
derive gPrint 	Record


Start world  = doHtmlServer MyPage4  world
Rinus Plasmeijer's avatar
Rinus Plasmeijer committed
18
19
//Start world  = doHtml MyPage  world

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

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

myrecord :: [Record]
myrecord = []

MyPage4 hst
# (myrecord,hst) = mkEditForm (Init,nFormId "bla" myrecord)  hst
=	mkHtml "Myrecord"
	[ H1 [] "myrecord"
	, BodyTag myrecord.form
	]  hst



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

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

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

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