October 2024
Intermediate to advanced
272 pages
6h 54m
English
Any respectable programming language has arrays or array-like collections (tuples, lists, vectors, matrices, you name it). Occam is not an exception. Occam arrays are homogeneous, have fixed sizes, and are created uninitialized. To create an array, specify its size, data type, name, and, optionally, values:
| | [4]BOOL enabled: -- An array of four Boolean values |
| | VAL trues IS [TRUE, TRUE, TRUE, TRUE]: -- An array of constants (a table) |
| | [8][8]BYTE board: -- An 8x8 array of bytes (a checkerboard) |
When describing an array or a table as a procedure parameter, don’t mention the size. Operator SIZE on line 6 of the next example will calculate it for you.
| 1: | -- Define the initializing ... |
Read now
Unlock full access