comparison extendlib.vistxt @ 0:76568becd6d6

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