Mercurial > repos > rhope
annotate extendlib.rhope @ 29:3cc5e4a42344
Missed registration for *@Real Number in previous commit
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 27 Jun 2009 01:50:33 -0400 |
parents | 8b2b3f4a2a58 |
children | 914ad38f9b59 |
rev | line source |
---|---|
0 | 1 |
2 Val[in:out] | |
3 { | |
4 out <- in | |
5 } | |
6 | |
7 _Map[list,index,worker:out] | |
8 { | |
9 newval <- [ | |
10 [worker]Do[ | |
11 [()]Append[ [list]Index[index] ] | |
12 ] | |
13 ]Index[0] | |
14 | |
15 [list]Next[index] | |
16 { | |
17 out <- [_Map[list, ~, worker]]Set[index, newval] | |
18 }{ | |
19 out <- [list]Set[index, newval] | |
20 } | |
21 } | |
22 | |
23 Map[list,worker:out] | |
24 { | |
25 [list]First | |
26 { | |
27 out <- _Map[list, ~, worker] | |
28 }{ | |
29 out <- list | |
30 } | |
31 } | |
32 | |
33 _Key Value Map[list,index,newlist,worker:out] | |
34 { | |
35 [worker]Do[ | |
36 [[()]Append[ [list]Index[index] ]]Append[index] | |
37 ] | |
38 { | |
39 newval <- [~]Index[0] | |
40 newkey <- [~]Index[1] | |
41 } | |
42 | |
43 next <- [newlist]Set[newkey, newval] | |
44 | |
45 [list]Next[index] | |
46 { | |
47 out <- _Key Value Map[list, ~, next, worker] | |
48 }{ | |
49 out <- Val[next] | |
50 } | |
51 } | |
52 | |
53 New Like@List[in:out] | |
54 { | |
55 out <- () | |
56 } | |
57 | |
58 New Like@Dictionary[in:out] | |
59 { | |
60 out <- New@Dictionary[] | |
61 } | |
62 | |
63 Key Value Map[list,worker:out] | |
64 { | |
65 [list]First | |
66 { | |
67 out <- _Key Value Map[list, ~, New Like[list], worker] | |
68 }{ | |
69 out <- New Like[list] | |
70 } | |
71 } | |
72 | |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
73 To String@String[string:out] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
74 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
75 out <- string |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
76 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
77 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
78 Empty@String[string:out] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
79 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
80 out <- "" |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
81 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
82 |
0 | 83 In[needle,haystack:found?] |
84 { | |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
85 [haystack]Get DString[To String[needle]] |
0 | 86 { |
87 found? <- Yes | |
88 } {} {} { | |
89 found? <- No | |
90 } | |
91 } | |
92 | |
93 Left Trim[string,trim:trimmed] | |
94 { | |
95 If[ [[string]Length] > [0] ] | |
96 { | |
97 first,rest <- [string]Slice[1] | |
98 If[ [first]In[trim] ] | |
99 { | |
100 trimmed <- Left Trim[rest, trim] | |
101 }{ | |
102 trimmed <- string | |
103 } | |
104 }{ | |
105 trimmed <- string | |
106 } | |
107 } | |
108 | |
109 Right Trim[string,trim:trimmed] | |
110 { | |
111 If[ [[string]Length] > [0] ] | |
112 { | |
113 rest,last <- [string]Slice[ [[string]Length] - [1]] | |
114 If[ [last]In[trim] ] | |
115 { | |
116 trimmed <- Right Trim[rest, trim] | |
117 }{ | |
118 trimmed <- string | |
119 } | |
120 }{ | |
121 trimmed <- string | |
122 } | |
123 } | |
124 | |
125 Trim[string,trim:trimmed] | |
126 { | |
127 left <- Left Trim[string, trim] | |
128 trimmed <- Right Trim[left, trim] | |
129 } | |
130 | |
131 Max[a,b:max] | |
132 { | |
133 If[[a] > [b]] | |
134 { | |
135 max <- a | |
136 }{ | |
137 max <- b | |
138 } | |
139 } | |
140 | |
141 Count Substring[string,substring:out] | |
142 { | |
143 out <- Max[[[[string]Split[substring]]Length] - [1], 0] | |
144 } | |
145 | |
146 _Key Value Join[dict,key,key sep,val sep,string:out] | |
147 { | |
148 new string <- [[[string]Append[key]]Append[key sep]]Append[ [dict]Index[key] ] | |
149 [dict]Next[key] | |
150 { | |
151 out <- _Key Value Join[dict, ~, key sep, val sep, [new string]Append[val sep]] | |
152 }{ | |
153 out <- Val[new string] | |
154 } | |
155 } | |
156 | |
157 Key Value Join[dict,key sep,val sep:out] | |
158 { | |
159 [dict]First | |
160 { | |
161 out <- _Key Value Join[dict, ~, key sep, val sep, ""] | |
162 }{ | |
163 out <- "" | |
164 } | |
165 } | |
166 | |
167 _Combine[source,dest,key:out] | |
168 { | |
169 new dest <- [dest]Set[key, [source]Index[key]] | |
170 [source]Next[key] | |
171 { | |
172 out <- _Combine[source, new dest, ~] | |
173 }{ | |
174 out <- Val[new dest] | |
175 } | |
176 } | |
177 | |
178 Combine[source,dest:out] | |
179 { | |
180 [source]First | |
181 { | |
182 out <- _Combine[source, dest, ~] | |
183 }{ | |
184 out <- dest | |
185 } | |
186 } | |
187 | |
188 _Fold[list,index,current,worker:out] | |
189 { | |
190 newval <- [ | |
191 [worker]Do[ | |
192 [[[()]Append[ current ]]Append[ [list]Index[index] ]]Append[index] | |
193 ] | |
194 ]Index[0] | |
195 | |
196 [list]Next[index] | |
197 { | |
198 out <- _Fold[list, ~, newval, worker] | |
199 }{ | |
200 out <- Val[newval] | |
201 } | |
202 } | |
203 | |
204 Fold[worker,start,list:out] | |
205 { | |
206 [list]First | |
207 { | |
208 out <- _Fold[list, ~, start, worker] | |
209 }{ | |
210 out <- start | |
211 } | |
212 } | |
213 | |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
214 _Zip[left,lindex,right,rindex,outlist:out] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
215 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
216 nlist <- [outlist]Append[ |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
217 [[()]Append[ [left]Index[lindex] ]]Append[ [right]Index[rindex] ] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
218 ] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
219 nlindex <- [left]Next[lindex] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
220 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
221 [right]Next[rindex] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
222 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
223 out <- _Zip[left,nlindex,right,~,nlist] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
224 }{ |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
225 out <- Val[nlist] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
226 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
227 }{ |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
228 out <- Val[nlist] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
229 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
230 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
231 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
232 Zip[left,right:out] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
233 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
234 lindex <- [left]First |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
235 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
236 Print[~] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
237 [right]First |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
238 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
239 Print[~] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
240 out <- _Zip[left,lindex,right,~,()] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
241 }{ |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
242 out <- () |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
243 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
244 }{ |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
245 out <- () |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
246 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
247 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
248 |
0 | 249 _Dict Split[dict,entry,index,keydelim:out] |
250 { | |
251 parts <- [entry]Split[keydelim] | |
252 out <- [dict]Set[[parts]Index[0],[parts]Index[1]] | |
253 } | |
254 | |
255 Dict Split[string,keydelim,entrydelim:out] | |
256 { | |
257 out <- Fold[["_Dict Split"]Set Input[3, keydelim], New@Dictionary[], [string]Split[entrydelim]] | |
258 } | |
259 | |
260 Previous@List[list,index:prev index,not found] | |
261 { | |
262 prev <- [index] - [1] | |
263 If[[prev] < [0]] | |
264 { | |
265 not found <- list | |
266 }{ | |
267 [list]Index[prev] | |
268 { | |
269 prev index <- Val[prev] | |
270 }{ | |
271 prev index, not found <- [list]Previous[prev] | |
272 } | |
273 } | |
274 } | |
275 | |
276 Last@List[list:out,not found] | |
277 { | |
278 out, not found <- [list]Previous[[list]Length] | |
279 } | |
280 | |
281 _Reverse Fold[list,index,start,worker:out] | |
282 { | |
283 newval <- [ | |
284 [worker]Do[ | |
285 [[[()]Append[ start ]]Append[ [list]Index[index] ]]Append[index] | |
286 ] | |
287 ]Index[0] | |
288 | |
289 [list]Previous[index] | |
290 { | |
291 out <- _Reverse Fold[list, ~, newval, worker] | |
292 }{ | |
293 out <- Val[newval] | |
294 } | |
295 } | |
296 | |
297 Reverse Fold[worker,start,list:out] | |
298 { | |
299 [list]Last | |
300 { | |
301 out <- _Reverse Fold[list, ~, start, worker] | |
302 }{ | |
303 out <- list | |
304 } | |
305 } | |
306 | |
307 _Join[list,delim,current,index:out] | |
308 { | |
309 [list]Next[index] | |
310 { | |
311 out <- _Join[list, delim, [[current]Append[delim]]Append[[list]Index[~]], ~] | |
312 }{ | |
313 out <- current | |
314 } | |
315 } | |
316 | |
317 Join[list,delim:out] | |
318 { | |
319 [list]First | |
320 { | |
321 out <- _Join[list, delim, [list]Index[~], ~] | |
322 }{ | |
323 out <- "" | |
324 } | |
325 } | |
326 | |
327 Replace[string,find,replace:replaced] | |
328 { | |
329 replaced <- [[string]Split[find]]Join[replace] | |
330 } | |
331 | |
332 Concatenate[left,right:out] | |
333 { | |
334 out <- Fold[["Append"]<String@Worker, left, right] | |
335 } | |
336 | |
337 Starts With[thing,starts with:out] | |
338 { | |
339 out <- [[thing]Slice[[starts with]Length]] = [starts with] | |
340 } | |
341 | |
342 Ends With[thing,ends with:out] | |
343 { | |
344 ,compare <- [thing]Slice[ [[thing]Length] - [[ends with]Length] ] | |
345 out <- [compare] = [ends with] | |
346 } | |
347 | |
348 As List@String[string:list] | |
349 { | |
350 list <- [()]Append[string] | |
351 } | |
352 | |
353 As List@List[in:out] | |
354 { | |
355 out <- in | |
356 } | |
357 | |
358 _Filter[list,index,worker,destlist:out] | |
359 { | |
360 filter? <- [ | |
361 [worker]Do[ | |
362 [()]Append[ [list]Index[index] ] | |
363 ] | |
364 ]Index[0] | |
365 If[filter?] | |
366 { | |
367 newlist <- [destlist]Append[[list]Index[index]] | |
368 }{ | |
369 newlist <- destlist | |
370 } | |
371 | |
372 [list]Next[index] | |
373 { | |
374 out <- _Filter[list, ~, worker, newlist] | |
375 }{ | |
376 out <- Val[newlist] | |
377 } | |
378 } | |
379 | |
380 Filter[list,worker:out] | |
381 { | |
382 [list]First | |
383 { | |
384 out <- _Filter[list, ~, worker, ()] | |
385 }{ | |
386 out <- list | |
387 } | |
388 } | |
389 | |
390 Pop@List[list:out] | |
391 { | |
392 [list]Last | |
393 { | |
394 out <- [list]Remove[~] | |
395 }{ | |
396 out <- list | |
397 } | |
398 } | |
399 | |
400 Peek@List[list:out,empty] | |
401 { | |
402 [list]Last | |
403 { | |
404 out <- [list]Index[~] | |
405 }{ | |
406 empty <- list | |
407 } | |
408 } | |
409 | |
410 Contains[haystack,needle:out] | |
411 { | |
412 [haystack]Get DString[needle] | |
413 { | |
414 out <- Yes | |
415 } {} {} { | |
416 out <- No | |
417 } | |
418 } | |
419 | |
420 _Find[haystack,needle,index:outindex,notfound] | |
421 { | |
422 If[[[haystack]Index[index]] = [needle]] | |
423 { | |
424 outindex <- index | |
425 }{ | |
426 [haystack]Next[index] | |
427 { | |
428 outindex,notfound <- _Find[haystack,needle,~] | |
429 }{ | |
430 notfound <- needle | |
431 } | |
432 } | |
433 } | |
434 | |
435 Find[haystack,needle:index,not found] | |
436 { | |
437 [haystack]First | |
438 { | |
439 index,not found <- _Find[haystack, needle, ~] | |
440 }{ | |
441 not found <- needle | |
442 } | |
443 | |
444 } | |
445 | |
446 Get Pretty Print Value[value:print,index,print indent,done,out value] | |
447 { | |
448 If[[Type Of[value]] = ["List"]] | |
449 { | |
450 out value <- value | |
451 list <- value | |
452 object <- value | |
453 }{ | |
454 If[[Type Of[value]] = ["Dictionary"]] | |
455 { | |
456 out value <- value | |
457 list <- value | |
458 object <- value | |
459 }{ | |
460 If[[Type Of[value]] = ["String"]] | |
461 { | |
462 out value <- value | |
463 print <- value | |
464 done <- 1 | |
465 }{ | |
466 If[[Type Of[value]] = ["Whole Number"]] | |
467 { | |
468 out value <- value | |
469 print <- value | |
470 done <- 1 | |
471 }{ | |
472 If[[Type Of[value]] = ["Yes No"]] | |
473 { | |
474 out value <- value | |
475 print <- value | |
476 done <- 1 | |
477 }{ | |
478 If[[Type Of[value]] = ["Real Number"]] | |
479 { | |
480 out value <- value | |
481 print <- value | |
482 done <- 1 | |
483 }{ | |
484 object <- value | |
485 fieldlist <- [Blueprint Of[value]]Get Fields | |
486 [fieldlist]First | |
487 { | |
488 list <- _Object to Dict[value, fieldlist, ~, New@Dictionary[]] | |
489 out value <- Val[list] | |
490 }{ | |
491 out value <- value | |
492 done <- 1 | |
493 } | |
494 } | |
495 } | |
496 } | |
497 } | |
498 | |
499 } | |
500 } | |
501 print <- Type Of[object] | |
502 index <- [list]First {} | |
503 { | |
504 print indent <- "{Empty}" | |
505 } | |
506 | |
507 } | |
508 | |
509 Pretty Print Helper[list,tabs,index:out] | |
510 { | |
511 newtabs <- [tabs]Append[" "] | |
512 print,new index,indented,done,value <- Get Pretty Print Value[[list]Index[index]] | |
513 Print[ [[[tabs]Append[index]]Append[": "]]Append[print] ] | |
514 { | |
515 done <- Pretty Print Helper[value,newtabs ,new index] | |
516 done <- Print[[newtabs]Append[indented]] | |
517 | |
518 Val[done] | |
519 { | |
520 [list]Next[index] | |
521 { | |
522 out <- Pretty Print Helper[list, tabs, ~] | |
523 }{ | |
524 out <- 1 | |
525 } | |
526 } | |
527 } | |
528 | |
529 } | |
530 | |
531 Pretty Print[toprint,tabs:out] | |
532 { | |
533 newtabs <- [tabs]Append[" "] | |
534 ,index,indented,,value <- Get Pretty Print Value[toprint] | |
535 { | |
536 Print[[tabs]Append[~]] | |
537 { | |
538 Pretty Print Helper[value,newtabs ,index] | |
539 Print[[newtabs]Append[indented]] | |
540 } | |
541 } | |
542 out <- 1 | |
543 } | |
544 | |
545 _Object to Dict[object,field list,index,dict:out] | |
546 { | |
547 field <- [field list]Index[index] | |
548 [object]Get Field[field] | |
549 { | |
550 nextdict <- [dict]Set[field, ~] | |
551 }{ | |
552 nextdict <- dict | |
553 } | |
554 [field list]Next[index] | |
555 { | |
556 out <- _Object to Dict[object, field list, ~, nextdict] | |
557 }{ | |
558 out <- Val[nextdict] | |
559 } | |
560 } | |
561 | |
562 _Keys[list,val,key:out] | |
563 { | |
564 out <- [list]Append[key] | |
565 } | |
566 | |
567 Keys[container:out] | |
568 { | |
569 out <- Fold["_Keys", New@List[], container] | |
570 } | |
571 | |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
572 And[left,right:out] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
573 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
574 ,out <- If[left] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
575 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
576 out,out <- If[right] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
577 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
578 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
579 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
580 Or[left,right:out] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
581 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
582 out <- If[left] {} |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
583 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
584 out,out <- If[right] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
585 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
586 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
587 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
588 After[text,prefix:after,not found] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
589 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
590 If[[text]Starts With[prefix]] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
591 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
592 ,after <- [text]Slice[[prefix]Length] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
593 }{ |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
594 not found <- text |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
595 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
596 } |
19
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
597 |
13 | 598 Blueprint Range |
599 { | |
600 Start | |
601 End | |
602 } | |
603 | |
604 Range[start,end:out] | |
605 { | |
606 out <- [[Build["Range"]]Start <<[start]]End <<[end] | |
607 } | |
608 | |
19
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
609 First@Range[range:out,none] |
13 | 610 { |
19
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
611 If[[[range]Start >>] < [[range]End >>]] |
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
612 { |
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
613 out <- [range]Start >> |
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
614 }{ |
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
615 none <- range |
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
616 } |
13 | 617 } |
618 | |
619 Next@Range[range,val:out,done] | |
620 { | |
621 next <- [val]+[1] | |
622 If[[next] < [[range]End >>]] | |
623 { | |
624 out <- Val[next] | |
625 }{ | |
626 done <- range | |
627 } | |
628 } | |
629 | |
630 Index@Range[range,index:out,notfound] | |
631 { | |
632 If[[index] < [[range]End >>]] | |
633 { | |
634 If[[index] < [[range]Start >>]] | |
635 { | |
636 notfound <- index | |
637 }{ | |
638 out <- index | |
639 } | |
640 }{ | |
641 notfound <- index | |
642 } | |
643 } | |
644 | |
24
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
645 Tail[list,start:out] |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
646 { |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
647 newlist <- New Like[list] |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
648 [list]Index[start] |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
649 { |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
650 out <- _Fold[list, start, newlist, "Append"] |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
651 }{ |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
652 out <- newlist |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
653 } |
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
654 } |
19
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
655 |
90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
Mike Pavone <pavone@retrodev.com>
parents:
13
diff
changeset
|
656 |
24
8b2b3f4a2a58
Some fixes to parser_old.rhope
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
657 |