Mercurial > repos > rhope
comparison dict.rhope @ 92:e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 02 Aug 2010 00:58:55 -0400 |
parents | c25d75c2440b |
children | fa437d23bb24 |
comparison
equal
deleted
inserted
replaced
91:bcdc326b3d6e | 92:e73a93fb5de1 |
---|---|
236 out,none <- [[dict]Right >>]_Next[key, keyidx, newkey] | 236 out,none <- [[dict]Right >>]_Next[key, keyidx, newkey] |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 _Print Dict[dict,key] | 241 _Print Seq[dict,key] |
242 { | 242 { |
243 val <- String[[dict]Index[key]] | 243 val <- String[[dict]Index[key]] |
244 Print[ [[["\t"]Append[String[key]]]Append[": "]]Append[val] ] | 244 Print[ [[["\t"]Append[String[key]]]Append[":\t"]]Append[val] ] |
245 { | 245 { |
246 [dict]Next[key] | 246 [dict]Next[key] |
247 { | 247 { |
248 _Print Dict[dict, ~] | 248 _Print Seq[dict, ~] |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 Print@Dictionary[dict:out] | 253 Print@Dictionary[dict:out] |
254 { | 254 { |
255 Print["Dictionary"] | 255 Print["Dictionary"] |
256 { _Print Dict[dict, [dict]First] } | 256 { _Print Seq[dict, [dict]First] } |
257 } | 257 } |
258 | 258 |
259 Print@Empty Dictionary[dict:out] | 259 Print@Empty Dictionary[dict:out] |
260 { | 260 { |
261 Print["Dictionary\n\t{Empty}"] | 261 Print["Dictionary\n\t{Empty}"] |
262 } | 262 } |
263 | 263 |
264 Length@Empty Dictionary[dict:out] | |
265 { | |
266 out <- 0 | |
267 } | |
268 | |
269 Length@Dictionary[dict:out] | |
270 { | |
271 If[[dict]Bits >>] | |
272 { | |
273 out <- [Length[[dict]Straight >>]]+[[Length[[dict]Left >>]] + [Length[[dict]Right >>]]] | |
274 }{ | |
275 out <- [1]+[[Length[[dict]Left >>]] + [Length[[dict]Right >>]]] | |
276 } | |
277 } | |
278 | |
279 _Combine[source,dest,key:out] | |
280 { | |
281 new dest <- [dest]Set[key, [source]Index[key]] | |
282 [source]Next[key] | |
283 { | |
284 out <- _Combine[source, new dest, ~] | |
285 }{ | |
286 out <- Val[new dest] | |
287 } | |
288 } | |
289 | |
290 Combine[source,dest:out] | |
291 { | |
292 [source]First | |
293 { | |
294 out <- _Combine[source, dest, ~] | |
295 }{ | |
296 out <- dest | |
297 } | |
298 } | |
299 |