On Tuesday, 13 May 2014 at 03:54:33 UTC, safety0ff wrote:
You should look into associative arrays ( http://dlang.org/hash-map .)

Example:

import std.stdio;

void main()
{
        int[][string] mybobs;
        mybobs["bob_1"] = [-1, -1, 1, -1, -1];
        mybobs["bob_2"] = [-1, 1, 1, 1, -1];
        mybobs["bob_3"] = [-1, 1, 1, 1, -1];
        writeln(mybobs);
}

Thanks for the quick reply, I'll look into that.

My issue is (which I didn't explain clearly, sorry) how do I do it with an unknown number of lines?
So my example has 3 lines. What if it had 300? or 3000?
Basically so I can run the same piece of code for any size file, and it will create a new named array for each line. So I assume(?) I have to do something that will "name" each of these arrays at runtime.

So,
for(x;1 ... n)
  bob_x = ...

Reply via email to