Mercurial > repos > rhope
annotate functional.rhope @ 123:4e4ecbca0b5d
Add bitwise and and or
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 Oct 2010 21:05:24 -0400 |
parents | f4fc0a98088a |
children |
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 | 24 _Map[list,worker,cur:out] |
25 { | |
26 val <- [list]Index[cur] | |
27 nlist <- [list]Set[cur, [worker]Call[val, cur]] | |
28 | |
29 [nlist]Next[cur] | |
30 { | |
31 out <- _Map[nlist, worker, ~] | |
32 }{ | |
33 out <- Val[nlist] | |
34 } | |
35 } | |
36 | |
37 Map[list,worker:out] | |
38 { | |
39 [list]First | |
40 { | |
41 out <- _Map[list,worker,~] | |
42 }{ | |
43 out <- list | |
44 } | |
45 } | |
46 | |
47 _Find[list,pred,cur:loc,not found] | |
48 { | |
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 | 51 { |
52 loc <- cur | |
53 }{ | |
54 ,not found <- [list]Next[cur] | |
55 { loc,not found <- _Find[list,pred,~] } | |
56 } | |
57 } | |
58 | |
59 Find[list,pred:loc,not found] | |
60 { | |
61 ,not found <- [list]First | |
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 | 64 } |
65 } | |
66 | |
67 _Filter[list,pred,cur,dest:out] | |
68 { | |
69 val <- [list]Index[cur] | |
70 If[[pred]Call[val,cur]] | |
71 { | |
72 ndest <- [dest]Append[val] | |
73 }{ | |
74 ndest <- dest | |
75 } | |
76 [list]Next[cur] | |
77 { | |
78 out <- _Filter[list,pred,~,ndest] | |
79 }{ | |
80 out <- Val[ndest] | |
81 } | |
82 } | |
83 | |
84 Filter[list,pred:out] | |
85 { | |
86 [list]First | |
87 { | |
88 out <- _Filter[list,pred,~, List[]] | |
89 }{ | |
90 out <- list | |
91 } | |
92 } | |
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 |