[clean-list] Array indexing in Clean (or: Das Wort zum Sonntag)

Siegfried Gonzi siegfried.gonzi@kfunigraz.ac.at
Sun, 02 Sep 2001 13:13:33 +0200


Concerning the question: Which index is running quicklier.

As it emerged, the rightmost index is running first in Clean, e.g.

a.[i,j]

i denotes the row and j denotes the column. So far nothing new.

But you should be aware that you get the most out (factor 5),
when you traverse the array with j first, because as in C
j sweeps through the successive array_memory_place. Whereas
i always has to jump the complete column. If you have to
estimate the index i, you should transpose the array for large
values of dimension, or you can use the one dimensional aggressive
array indexing: j + i*columns

The Clean book writes that the access-time of arrays are
in constant time. I mean that this is only valid for one
dimension, respectively.


S. Gonzi