In my programming environment I have quite big 2D array. Its size is 90x40.
I have to fill this array by loading the data from external file.
The mechanism of loading the data consists of a binding file in which I have to do the binding in style like below:
Array[0][0] =
Array[0][1] =
Array[0][2] =
...
Array[20][37] =
Array[20][38] =
...
Array[89][38] =
Array[89][39] =
It easy to compute that I have to create 3600 partially unique lines.
I thought that I can create the [..][..] elements in gVim and then add in front of them the name of the array. Although adding prefix is easy, I stuck on creating [..][..] bit.
In my scenario I want to solve this by doing something like:
- create 3600 rows
- add at the end of the each row/line (by using the
:%s/$/\[ -- my expression 1 -- \]/g
command) numbers from 0 to 89 in blocks of forty elements (forty zeros, forty ones, forty twos, etc.) - add at the end of the each row/line (by using the
:%s/$/\[ -- my expression 2-- \]/g
command) numbers from 0 to 39 in blocks of forty elements (zero, one, two, ..., thirty nine, zero, one, ...,etc.)
my expression 1 would evaluate to the quotient of the operation (number of line) mod 90
my expression 2 would evaluate to the reminder of the operation (number of line) mod 40
And the questions now are:
- how to evaluate
(number of line)
- how to calculate the
(number of line) mod XX
expression? - maybe there is a better approach?