09Lists
Lists of lists
Build tables and grids from lists whose cells are lists, and walk them with addresses.
A cell can hold a whole list. A list of rows is a table:
Expected output
[[၀၊ ၀၊ ၀]၊ [၀၊ ၀၊ ၉]]
[၀၊ ၀၊ ၉]
၂
၃
Each count prefix pairs with one စာရင်း, the inner ones first: in
အကွက် ၂ ခုရှိသော အကွက် ၃ ခုရှိသော ကိန်းပြည့် စာရင်း စာရင်း, the ၃ belongs to the
first စာရင်း (a row of 3 integers) and the ၂ to the second (2 such rows). Messages
write this kind as [2][3]isize. Lists nest as deep as needed.
Nested literals
Each inner list literal goes in parentheses. A kind with no counts takes all of them from the value:
Expected output
[[၁၊ ၂]၊ [၃၊ ၄]၊ [၅၊ ၆]]
၅
[[၅၊ ၆]၊ [၃၊ ၄]၊ [၅၊ ၆]]
Rows and cells through addresses
The address of a list points at the whole list, so its kind holds the count:
ငှားထားသော အကွက် ၃ ခုရှိသော ကိန်းပြည့် စာရင်း လိပ်စာ, or &*[3]isize in messages. Adding 1 to it
moves one whole row:
Expected output
[၁၊ ၂၊ ၃]
[၄၊ ၅၊ ၆]
၆
The address of one cell is a plain pointer, and pointer arithmetic walks the cells after it:
Expected output
၂
၇
The size of a list
A list takes its count times the size of one cell, with no gaps:
Expected output
၄၈
Hands on
- Fill a 3 x 3 table so that each cell holds its row number times its column number, and print it.
- Walk a row of a table with a cell pointer and add up its cells.
Next: List mistakes.