Resuming some recreational Algol 68 programming I'm working on an array-of-array (row-of-row) structure. I started as so often with[code snipped -- ANW]
a specific function, say,
-a-a-a PROC permute_nums = (REF MAT m) VOID :
-a-a-a-a-a-a-a FOR y TO 1 UPB m DO
-a-a-a-a-a-a-a-a-a-a-a FOR x TO 2 UPB m DO
-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a REF INT where = m [y, x];
-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a where := num [where]
-a-a-a-a-a-a-a-a-a-a-a OD
-a-a-a-a-a-a-a OD;
Since these nested loops are clumsy and are expected to appear in
some more functions I added a generic variant
where the specific transformation function is passed as a parameter.
Now I'm not too much concerned about performance but more about the
clarity of the source code. [...]
Comments on these ruminations, thoughts and ideas, are welcome.I don't feel that four lines of code to iterate through a two- dimensional array is difficult to write or understand. If it was a 6D
On 14/04/2026 14:04, Janis Papanagnou wrote:
Resuming some recreational Algol 68 programming I'm working on an-a-a [code snipped -- ANW]
array-of-array (row-of-row) structure. I started as so often with
a specific function, say,
-a-a-a-a PROC permute_nums = (REF MAT m) VOID :
-a-a-a-a-a-a-a-a FOR y TO 1 UPB m DO
-a-a-a-a-a-a-a-a-a-a-a-a FOR x TO 2 UPB m DO
-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a REF INT where = m [y, x];
-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a where := num [where]
-a-a-a-a-a-a-a-a-a-a-a-a OD
-a-a-a-a-a-a-a-a OD;
Since these nested loops are clumsy and are expected to appear in
some more functions I added a generic variant
where the specific transformation function is passed as a parameter.
Now I'm not too much concerned about performance but more about the
clarity of the source code. [...]
-a-a-a-aPersonally, I find the non-generic version clearer.-a ISTM that you're opening cans of worms with the generic version as well as making
the code harder to understand.
[ identified problem with 'print'-like code snipped ]
Comments on these ruminations, thoughts and ideas, are welcome.
-a-a-a-aI don't feel that four lines of code to iterate through a two- dimensional array is difficult to write or understand.
If it was a 6D
array, you might [IMO] have more reason to avoid repeating the obvious loops.-a OTOH, that might give you cause to simplify the data structures
or take a different approach, such as pre-processing the code.
-a-a-a-a[I once, some years ago, spent a lot of time solving puzzles involving tree searches (eg, for Slitherlink, Light-Up and Hashi).-a I
tried to write generic code for the relevant parallel processing, but
in the end it was (much) easier to write the specific code for one
puzzle and copy-and-edit it for the next puzzle.-a YMMV.]
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 05:11:25 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
921 files (14,318M bytes) |
| Messages: | 264,602 |