Last active 1735184955

Revision b42e6fec9759c6dfec775c179214fe5b9df335c3

tables-with-var-pass.nv Raw Playground
1|#variables|
2 , @table id, @table row, @table size
3 , pretty print rows iterator, pretty print row index
4
5
6|_| Define our tables
7|#table, singles|
8 , 1st
9
10|#table, doubles|
11 , 1st, 2nd
12
13|#table, triples|
14 , 1st, 2nd, 3rd
15
16
17|_| Operations to select a table by id
18 Hand written to show a general pattern for this
19|set (@table id) to (singles) table| @table id:1
20|set (@table id) to (doubles) table| @table id:2
21|set (@table id) to (triples) table| @table id:3
22
23|select (singles) table|
24 , clear (@table id)
25 , set (@table id) to (singles) table
26
27|select (doubles) table|
28 , clear (@table id)
29 , set (@table id) to (doubles) table
30
31|select (triples) table|
32 , clear (@table id)
33 , set (@table id) to (triples) table
34
35
36
37|_| ports for reading the size of a table
38|#port, on get table size
39 , needs, @get table size
40 , reads, @table id|
41 , @table size, @no such table
42|#port body, on get table size, lua|
43 if self.tables[table_id] then
44 counters["@table size"] = #self.tables[table_id]
45 else
46 counters["@no such table"] = 1
47 end
48
49
50|_| Read data from the command line and pump it into a table.
51|#port, on read singles, needs, @read singles|
52|#port body, on read singles, lua|
53 local input = io.read("*a")
54 for left, right in input:gmatch("(%d+)") do
55 self.tables:push_row("singles",
56 { ["1st"] = tonumber(left) or 0
57 }
58 )
59 end
60
61|#port, on read doubles, needs, @read doubles|
62|#port body, on read doubles, lua|
63 local input = io.read("*a")
64 for left, right in input:gmatch("(%d+),%s*(%d+)") do
65 self.tables:push_row("doubles",
66 { ["1st"] = tonumber(left) or 0
67 , ["2nd"] = tonumber(right) or 0
68 }
69 )
70 end
71
72|#port, on read triples, needs, @read triples|
73|#port body, on read triples, lua|
74 local input = io.read("*a")
75 for left, right in input:gmatch("(%d+),%s*(%d+),%s*(%d+)") do
76 self.tables:push_row("triples",
77 { ["1st"] = tonumber(left) or 0
78 , ["2nd"] = tonumber(right) or 0
79 , ["3rd"] = tonumber(right) or 0
80 }
81 )
82 end
83
84
85|_| A generic operations over a table
86|#port, on pretty print row
87 , needs, @pretty print row,
88 , reads, @table id, @table row|
89|#port body, on pretty print row, lua|
90 local rows = self.tables[table_id]
91 local row = rows[table_row]
92 io.write(rows.name .. " #" .. tostring(table_row) .. ": ")
93 local mapping = self.tables.mappings[rows.name]
94 local assembled_row = {}
95 for key, index in pairs(mapping) do
96 assembled_row[key] = row[index]
97 end
98 pprint(assembled_row)
99
100
101
102|_| loop to pretty print the rows of any table
103|pretty print rows|
104 , clear (@table row)
105 , get table size for (pretty print rows)
106 , pretty printing rows
107
108|get table size for (pretty print rows)|
109 , @get table size
110 , move (@table size) to (pretty print rows iterator)
111
112|pretty printing rows, pretty print rows iterator|
113 , pretty print row index
114 , copy (pretty print row index) to (@table row)
115 , pretty print row
116 , next pretty print rows
117
118|pretty printing rows|
119
120|pretty print row|
121 , @pretty print row
122
123|next pretty print rows|
124 , pretty printing rows
125
126|pretty print row index|
127
128
129|| 1st: read singles
130 , 2nd: pretty print singles
131 , 3rd: read doubles
132 , 4th: pretty print doubles
133 , 5th: read triples
134 , 6th: pretty print triples
135
136|1st: read singles|
137 , @read singles
138
139|2nd: pretty print singles|
140 , select (singles) table
141 , pretty print rows
142
143|3rd: read doubles|
144 , @read doubles
145
146|4th: pretty print doubles|
147 , select (doubles) table
148 , pretty print rows
149
150|5th: read triples|
151 , @read triples
152
153|6th: pretty print triples|
154 , select (triples) table
155 , pretty print rows
tables-with-var-pass.processed.nv Raw Playground
1|clearing (@table id), @table id|
2
3|clearing (@table id)|
4
5|clear (@table id)|
6 , clearing (@table id):9007199254740991
7
8|clearing (@table row), @table row|
9
10|clearing (@table row)|
11
12|clear (@table row)|
13 , clearing (@table row):9007199254740991
14
15|clearing (@table size), @table size|
16
17|clearing (@table size)|
18
19|clear (@table size)|
20 , clearing (@table size):9007199254740991
21
22|clearing (pretty print rows iterator), pretty print rows iterator|
23
24|clearing (pretty print rows iterator)|
25
26|clear (pretty print rows iterator)|
27 , clearing (pretty print rows iterator):9007199254740991
28
29|clearing (pretty print row index), pretty print row index|
30
31|clearing (pretty print row index)|
32
33|clear (pretty print row index)|
34 , clearing (pretty print row index):9007199254740991
35
36|restoring (@table id), temporary (@table id)|
37 , restoring (@table id)
38 , @table id
39
40|restoring (@table id)|
41
42|restore (@table id)|
43 , restoring (@table id):9007199254740991
44
45|restoring (@table row), temporary (@table row)|
46 , restoring (@table row)
47 , @table row
48
49|restoring (@table row)|
50
51|restore (@table row)|
52 , restoring (@table row):9007199254740991
53
54|restoring (@table size), temporary (@table size)|
55 , restoring (@table size)
56 , @table size
57
58|restoring (@table size)|
59
60|restore (@table size)|
61 , restoring (@table size):9007199254740991
62
63|restoring (pretty print rows iterator), temporary (pretty print rows iterator)|
64 , restoring (pretty print rows iterator)
65 , pretty print rows iterator
66
67|restoring (pretty print rows iterator)|
68
69|restore (pretty print rows iterator)|
70 , restoring (pretty print rows iterator):9007199254740991
71
72|restoring (pretty print row index), temporary (pretty print row index)|
73 , restoring (pretty print row index)
74 , pretty print row index
75
76|restoring (pretty print row index)|
77
78|restore (pretty print row index)|
79 , restoring (pretty print row index):9007199254740991
80
81|moving (@table id) to (@table row), @table id|
82 , moving (@table id) to (@table row)
83 , @table row
84
85|moving (@table id) to (@table row)|
86
87|move (@table id) to (@table row)|
88 , clear (@table row)
89 , moving (@table id) to (@table row):9007199254740991
90
91|moving (@table id) to (@table size), @table id|
92 , moving (@table id) to (@table size)
93 , @table size
94
95|moving (@table id) to (@table size)|
96
97|move (@table id) to (@table size)|
98 , clear (@table size)
99 , moving (@table id) to (@table size):9007199254740991
100
101|moving (@table id) to (pretty print rows iterator), @table id|
102 , moving (@table id) to (pretty print rows iterator)
103 , pretty print rows iterator
104
105|moving (@table id) to (pretty print rows iterator)|
106
107|move (@table id) to (pretty print rows iterator)|
108 , clear (pretty print rows iterator)
109 , moving (@table id) to (pretty print rows iterator):9007199254740991
110
111|moving (@table id) to (pretty print row index), @table id|
112 , moving (@table id) to (pretty print row index)
113 , pretty print row index
114
115|moving (@table id) to (pretty print row index)|
116
117|move (@table id) to (pretty print row index)|
118 , clear (pretty print row index)
119 , moving (@table id) to (pretty print row index):9007199254740991
120
121|moving (@table row) to (@table id), @table row|
122 , moving (@table row) to (@table id)
123 , @table id
124
125|moving (@table row) to (@table id)|
126
127|move (@table row) to (@table id)|
128 , clear (@table id)
129 , moving (@table row) to (@table id):9007199254740991
130
131|moving (@table row) to (@table size), @table row|
132 , moving (@table row) to (@table size)
133 , @table size
134
135|moving (@table row) to (@table size)|
136
137|move (@table row) to (@table size)|
138 , clear (@table size)
139 , moving (@table row) to (@table size):9007199254740991
140
141|moving (@table row) to (pretty print rows iterator), @table row|
142 , moving (@table row) to (pretty print rows iterator)
143 , pretty print rows iterator
144
145|moving (@table row) to (pretty print rows iterator)|
146
147|move (@table row) to (pretty print rows iterator)|
148 , clear (pretty print rows iterator)
149 , moving (@table row) to (pretty print rows iterator):9007199254740991
150
151|moving (@table row) to (pretty print row index), @table row|
152 , moving (@table row) to (pretty print row index)
153 , pretty print row index
154
155|moving (@table row) to (pretty print row index)|
156
157|move (@table row) to (pretty print row index)|
158 , clear (pretty print row index)
159 , moving (@table row) to (pretty print row index):9007199254740991
160
161|moving (@table size) to (@table id), @table size|
162 , moving (@table size) to (@table id)
163 , @table id
164
165|moving (@table size) to (@table id)|
166
167|move (@table size) to (@table id)|
168 , clear (@table id)
169 , moving (@table size) to (@table id):9007199254740991
170
171|moving (@table size) to (@table row), @table size|
172 , moving (@table size) to (@table row)
173 , @table row
174
175|moving (@table size) to (@table row)|
176
177|move (@table size) to (@table row)|
178 , clear (@table row)
179 , moving (@table size) to (@table row):9007199254740991
180
181|moving (@table size) to (pretty print rows iterator), @table size|
182 , moving (@table size) to (pretty print rows iterator)
183 , pretty print rows iterator
184
185|moving (@table size) to (pretty print rows iterator)|
186
187|move (@table size) to (pretty print rows iterator)|
188 , clear (pretty print rows iterator)
189 , moving (@table size) to (pretty print rows iterator):9007199254740991
190
191|moving (@table size) to (pretty print row index), @table size|
192 , moving (@table size) to (pretty print row index)
193 , pretty print row index
194
195|moving (@table size) to (pretty print row index)|
196
197|move (@table size) to (pretty print row index)|
198 , clear (pretty print row index)
199 , moving (@table size) to (pretty print row index):9007199254740991
200
201|moving (pretty print rows iterator) to (@table id), pretty print rows iterator|
202 , moving (pretty print rows iterator) to (@table id)
203 , @table id
204
205|moving (pretty print rows iterator) to (@table id)|
206
207|move (pretty print rows iterator) to (@table id)|
208 , clear (@table id)
209 , moving (pretty print rows iterator) to (@table id):9007199254740991
210
211|moving (pretty print rows iterator) to (@table row), pretty print rows iterator|
212 , moving (pretty print rows iterator) to (@table row)
213 , @table row
214
215|moving (pretty print rows iterator) to (@table row)|
216
217|move (pretty print rows iterator) to (@table row)|
218 , clear (@table row)
219 , moving (pretty print rows iterator) to (@table row):9007199254740991
220
221|moving (pretty print rows iterator) to (@table size), pretty print rows iterator|
222 , moving (pretty print rows iterator) to (@table size)
223 , @table size
224
225|moving (pretty print rows iterator) to (@table size)|
226
227|move (pretty print rows iterator) to (@table size)|
228 , clear (@table size)
229 , moving (pretty print rows iterator) to (@table size):9007199254740991
230
231|moving (pretty print rows iterator) to (pretty print row index), pretty print rows iterator|
232 , moving (pretty print rows iterator) to (pretty print row index)
233 , pretty print row index
234
235|moving (pretty print rows iterator) to (pretty print row index)|
236
237|move (pretty print rows iterator) to (pretty print row index)|
238 , clear (pretty print row index)
239 , moving (pretty print rows iterator) to (pretty print row index):9007199254740991
240
241|moving (pretty print row index) to (@table id), pretty print row index|
242 , moving (pretty print row index) to (@table id)
243 , @table id
244
245|moving (pretty print row index) to (@table id)|
246
247|move (pretty print row index) to (@table id)|
248 , clear (@table id)
249 , moving (pretty print row index) to (@table id):9007199254740991
250
251|moving (pretty print row index) to (@table row), pretty print row index|
252 , moving (pretty print row index) to (@table row)
253 , @table row
254
255|moving (pretty print row index) to (@table row)|
256
257|move (pretty print row index) to (@table row)|
258 , clear (@table row)
259 , moving (pretty print row index) to (@table row):9007199254740991
260
261|moving (pretty print row index) to (@table size), pretty print row index|
262 , moving (pretty print row index) to (@table size)
263 , @table size
264
265|moving (pretty print row index) to (@table size)|
266
267|move (pretty print row index) to (@table size)|
268 , clear (@table size)
269 , moving (pretty print row index) to (@table size):9007199254740991
270
271|moving (pretty print row index) to (pretty print rows iterator), pretty print row index|
272 , moving (pretty print row index) to (pretty print rows iterator)
273 , pretty print rows iterator
274
275|moving (pretty print row index) to (pretty print rows iterator)|
276
277|move (pretty print row index) to (pretty print rows iterator)|
278 , clear (pretty print rows iterator)
279 , moving (pretty print row index) to (pretty print rows iterator):9007199254740991
280
281|copying (@table id) to (@table row), @table id|
282 , copying (@table id) to (@table row)
283 , temporary (@table id)
284 , @table row
285
286|copying (@table id) to (@table row)|
287
288|copy (@table id) to (@table row)|
289 , clear (@table row)
290 , copying (@table id) to (@table row):9007199254740991
291 , then restore (@table id)
292
293|copying (@table id) to (@table size), @table id|
294 , copying (@table id) to (@table size)
295 , temporary (@table id)
296 , @table size
297
298|copying (@table id) to (@table size)|
299
300|copy (@table id) to (@table size)|
301 , clear (@table size)
302 , copying (@table id) to (@table size):9007199254740991
303 , then restore (@table id)
304
305|copying (@table id) to (pretty print rows iterator), @table id|
306 , copying (@table id) to (pretty print rows iterator)
307 , temporary (@table id)
308 , pretty print rows iterator
309
310|copying (@table id) to (pretty print rows iterator)|
311
312|copy (@table id) to (pretty print rows iterator)|
313 , clear (pretty print rows iterator)
314 , copying (@table id) to (pretty print rows iterator):9007199254740991
315 , then restore (@table id)
316
317|copying (@table id) to (pretty print row index), @table id|
318 , copying (@table id) to (pretty print row index)
319 , temporary (@table id)
320 , pretty print row index
321
322|copying (@table id) to (pretty print row index)|
323
324|copy (@table id) to (pretty print row index)|
325 , clear (pretty print row index)
326 , copying (@table id) to (pretty print row index):9007199254740991
327 , then restore (@table id)
328
329|copying (@table row) to (@table id), @table row|
330 , copying (@table row) to (@table id)
331 , temporary (@table row)
332 , @table id
333
334|copying (@table row) to (@table id)|
335
336|copy (@table row) to (@table id)|
337 , clear (@table id)
338 , copying (@table row) to (@table id):9007199254740991
339 , then restore (@table row)
340
341|copying (@table row) to (@table size), @table row|
342 , copying (@table row) to (@table size)
343 , temporary (@table row)
344 , @table size
345
346|copying (@table row) to (@table size)|
347
348|copy (@table row) to (@table size)|
349 , clear (@table size)
350 , copying (@table row) to (@table size):9007199254740991
351 , then restore (@table row)
352
353|copying (@table row) to (pretty print rows iterator), @table row|
354 , copying (@table row) to (pretty print rows iterator)
355 , temporary (@table row)
356 , pretty print rows iterator
357
358|copying (@table row) to (pretty print rows iterator)|
359
360|copy (@table row) to (pretty print rows iterator)|
361 , clear (pretty print rows iterator)
362 , copying (@table row) to (pretty print rows iterator):9007199254740991
363 , then restore (@table row)
364
365|copying (@table row) to (pretty print row index), @table row|
366 , copying (@table row) to (pretty print row index)
367 , temporary (@table row)
368 , pretty print row index
369
370|copying (@table row) to (pretty print row index)|
371
372|copy (@table row) to (pretty print row index)|
373 , clear (pretty print row index)
374 , copying (@table row) to (pretty print row index):9007199254740991
375 , then restore (@table row)
376
377|copying (@table size) to (@table id), @table size|
378 , copying (@table size) to (@table id)
379 , temporary (@table size)
380 , @table id
381
382|copying (@table size) to (@table id)|
383
384|copy (@table size) to (@table id)|
385 , clear (@table id)
386 , copying (@table size) to (@table id):9007199254740991
387 , then restore (@table size)
388
389|copying (@table size) to (@table row), @table size|
390 , copying (@table size) to (@table row)
391 , temporary (@table size)
392 , @table row
393
394|copying (@table size) to (@table row)|
395
396|copy (@table size) to (@table row)|
397 , clear (@table row)
398 , copying (@table size) to (@table row):9007199254740991
399 , then restore (@table size)
400
401|copying (@table size) to (pretty print rows iterator), @table size|
402 , copying (@table size) to (pretty print rows iterator)
403 , temporary (@table size)
404 , pretty print rows iterator
405
406|copying (@table size) to (pretty print rows iterator)|
407
408|copy (@table size) to (pretty print rows iterator)|
409 , clear (pretty print rows iterator)
410 , copying (@table size) to (pretty print rows iterator):9007199254740991
411 , then restore (@table size)
412
413|copying (@table size) to (pretty print row index), @table size|
414 , copying (@table size) to (pretty print row index)
415 , temporary (@table size)
416 , pretty print row index
417
418|copying (@table size) to (pretty print row index)|
419
420|copy (@table size) to (pretty print row index)|
421 , clear (pretty print row index)
422 , copying (@table size) to (pretty print row index):9007199254740991
423 , then restore (@table size)
424
425|copying (pretty print rows iterator) to (@table id), pretty print rows iterator|
426 , copying (pretty print rows iterator) to (@table id)
427 , temporary (pretty print rows iterator)
428 , @table id
429
430|copying (pretty print rows iterator) to (@table id)|
431
432|copy (pretty print rows iterator) to (@table id)|
433 , clear (@table id)
434 , copying (pretty print rows iterator) to (@table id):9007199254740991
435 , then restore (pretty print rows iterator)
436
437|copying (pretty print rows iterator) to (@table row), pretty print rows iterator|
438 , copying (pretty print rows iterator) to (@table row)
439 , temporary (pretty print rows iterator)
440 , @table row
441
442|copying (pretty print rows iterator) to (@table row)|
443
444|copy (pretty print rows iterator) to (@table row)|
445 , clear (@table row)
446 , copying (pretty print rows iterator) to (@table row):9007199254740991
447 , then restore (pretty print rows iterator)
448
449|copying (pretty print rows iterator) to (@table size), pretty print rows iterator|
450 , copying (pretty print rows iterator) to (@table size)
451 , temporary (pretty print rows iterator)
452 , @table size
453
454|copying (pretty print rows iterator) to (@table size)|
455
456|copy (pretty print rows iterator) to (@table size)|
457 , clear (@table size)
458 , copying (pretty print rows iterator) to (@table size):9007199254740991
459 , then restore (pretty print rows iterator)
460
461|copying (pretty print rows iterator) to (pretty print row index), pretty print rows iterator|
462 , copying (pretty print rows iterator) to (pretty print row index)
463 , temporary (pretty print rows iterator)
464 , pretty print row index
465
466|copying (pretty print rows iterator) to (pretty print row index)|
467
468|copy (pretty print rows iterator) to (pretty print row index)|
469 , clear (pretty print row index)
470 , copying (pretty print rows iterator) to (pretty print row index):9007199254740991
471 , then restore (pretty print rows iterator)
472
473|copying (pretty print row index) to (@table id), pretty print row index|
474 , copying (pretty print row index) to (@table id)
475 , temporary (pretty print row index)
476 , @table id
477
478|copying (pretty print row index) to (@table id)|
479
480|copy (pretty print row index) to (@table id)|
481 , clear (@table id)
482 , copying (pretty print row index) to (@table id):9007199254740991
483 , then restore (pretty print row index)
484
485|copying (pretty print row index) to (@table row), pretty print row index|
486 , copying (pretty print row index) to (@table row)
487 , temporary (pretty print row index)
488 , @table row
489
490|copying (pretty print row index) to (@table row)|
491
492|copy (pretty print row index) to (@table row)|
493 , clear (@table row)
494 , copying (pretty print row index) to (@table row):9007199254740991
495 , then restore (pretty print row index)
496
497|copying (pretty print row index) to (@table size), pretty print row index|
498 , copying (pretty print row index) to (@table size)
499 , temporary (pretty print row index)
500 , @table size
501
502|copying (pretty print row index) to (@table size)|
503
504|copy (pretty print row index) to (@table size)|
505 , clear (@table size)
506 , copying (pretty print row index) to (@table size):9007199254740991
507 , then restore (pretty print row index)
508
509|copying (pretty print row index) to (pretty print rows iterator), pretty print row index|
510 , copying (pretty print row index) to (pretty print rows iterator)
511 , temporary (pretty print row index)
512 , pretty print rows iterator
513
514|copying (pretty print row index) to (pretty print rows iterator)|
515
516|copy (pretty print row index) to (pretty print rows iterator)|
517 , clear (pretty print rows iterator)
518 , copying (pretty print row index) to (pretty print rows iterator):9007199254740991
519 , then restore (pretty print row index)
520
521|then restore (@table id)|
522 , restore (@table id)
523
524|then restore (@table row)|
525 , restore (@table row)
526
527|then restore (@table size)|
528 , restore (@table size)
529
530|then restore (pretty print rows iterator)|
531 , restore (pretty print rows iterator)
532
533|then restore (pretty print row index)|
534 , restore (pretty print row index)
535
536|_|
537 , Define our tables
538
539|_|
540 , Operations to select a table by id Hand written to show a general pattern for this
541
542|set (@table id) to (singles) table|
543 , @table id:1
544
545|set (@table id) to (doubles) table|
546 , @table id:2
547
548|set (@table id) to (triples) table|
549 , @table id:3
550
551|select (singles) table|
552 , clear (@table id)
553 , set (@table id) to (singles) table
554
555|select (doubles) table|
556 , clear (@table id)
557 , set (@table id) to (doubles) table
558
559|select (triples) table|
560 , clear (@table id)
561 , set (@table id) to (triples) table
562
563|_|
564 , ports for reading the size of a table
565
566|_|
567 , Read data from the command line and pump it into a table.
568
569|_|
570 , A generic operations over a table
571
572|_|
573 , loop to pretty print the rows of any table
574
575|pretty print rows|
576 , clear (@table row)
577 , get table size for (pretty print rows)
578 , pretty printing rows
579
580|get table size for (pretty print rows)|
581 , @get table size
582 , move (@table size) to (pretty print rows iterator)
583
584|pretty printing rows, pretty print rows iterator|
585 , pretty print row index
586 , copy (pretty print row index) to (@table row)
587 , pretty print row
588 , next pretty print rows
589
590|pretty printing rows|
591
592|pretty print row|
593 , @pretty print row
594
595|next pretty print rows|
596 , pretty printing rows
597
598|pretty print row index|
599
600||
601 , 1st: read singles
602 , 2nd: pretty print singles
603 , 3rd: read doubles
604 , 4th: pretty print doubles
605 , 5th: read triples
606 , 6th: pretty print triples
607
608|1st: read singles|
609 , @read singles
610
611|2nd: pretty print singles|
612 , select (singles) table
613 , pretty print rows
614
615|3rd: read doubles|
616 , @read doubles
617
618|4th: pretty print doubles|
619 , select (doubles) table
620 , pretty print rows
621
622|5th: read triples|
623 , @read triples
624
625|6th: pretty print triples|
626 , select (triples) table
627 , pretty print rows
628
629