annotate functional.rhope @ 156:ed70399a07aa

Add Substring method to string and improve performance of Partition
author Mike Pavone <pavone@retrodev.com>
date Thu, 23 Dec 2010 02:00:27 +0000
parents f4fc0a98088a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
75
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 _Fold[list,index,current,worker:out]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 newval <- [worker]Call[current, [list]Index[index], index]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 [list]Next[index]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 out <- _Fold[list, ~, newval, worker]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 }{
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 out <- Val[newval]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 Fold[worker,start,list:out]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 [list]First
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 out <- _Fold[list, ~, start, worker]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 }{
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 out <- start
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23
84
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
24 _Map[list,worker,cur:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
25 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
26 val <- [list]Index[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
27 nlist <- [list]Set[cur, [worker]Call[val, cur]]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
28
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
29 [nlist]Next[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
30 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
31 out <- _Map[nlist, worker, ~]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
32 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
33 out <- Val[nlist]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
34 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
35 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
36
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
37 Map[list,worker:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
38 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
39 [list]First
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
40 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
41 out <- _Map[list,worker,~]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
42 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
43 out <- list
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
44 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
45 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
46
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
47 _Find[list,pred,cur:loc,not found]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
48 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
49 val <- [list]Index[cur]
101
f4fc0a98088a Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents: 98
diff changeset
50 If[[pred]Call[val,cur]]
84
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
51 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
52 loc <- cur
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
53 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
54 ,not found <- [list]Next[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
55 { loc,not found <- _Find[list,pred,~] }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
56 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
57 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
58
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
59 Find[list,pred:loc,not found]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
60 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
61 ,not found <- [list]First
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
62 {
92
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 84
diff changeset
63 loc,not found <- _Find[list,pred,~]
84
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
64 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
65 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
66
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
67 _Filter[list,pred,cur,dest:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
68 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
69 val <- [list]Index[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
70 If[[pred]Call[val,cur]]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
71 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
72 ndest <- [dest]Append[val]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
73 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
74 ndest <- dest
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
75 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
76 [list]Next[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
77 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
78 out <- _Filter[list,pred,~,ndest]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
79 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
80 out <- Val[ndest]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
81 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
82 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
83
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
84 Filter[list,pred:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
85 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
86 [list]First
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
87 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
88 out <- _Filter[list,pred,~, List[]]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
89 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
90 out <- list
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
91 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
92 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
93
98
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
94 _Zip[left,lindex,right,rindex,outlist:out]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
95 {
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
96 nlist <- [outlist]Append[
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
97 [[()]Append[ [left]Index[lindex] ]]Append[ [right]Index[rindex] ]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
98 ]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
99 nlindex <- [left]Next[lindex]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
100 {
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
101 [right]Next[rindex]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
102 {
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
103 out <- _Zip[left,nlindex,right,~,nlist]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
104 }{
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
105 out <- Val[nlist]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
106 }
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
107 }{
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
108 out <- Val[nlist]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
109 }
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
110 }
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
111
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
112 Zip[left,right:out]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
113 {
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
114 lindex <- [left]First
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
115 {
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
116 [right]First
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
117 {
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
118 out <- _Zip[left,lindex,right,~,()]
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
119 }{
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
120 out <- ()
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
121 }
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
122 }{
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
123 out <- ()
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
124 }
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
125 }
a34a982ecd32 Broken port of nworker to compiler
Mike Pavone <pavone@retrodev.com>
parents: 92
diff changeset
126