On Tuesday, 13 December 2016 at 21:13:26 UTC, Ali wrote:
And extending Ali's solution you can actually get the data in
to a two dimentional array at compile time and have it in
static memory with a small adjustment:
static immutable matrix = import("data.txt")
.split("\n")
.map!(a => a.split(",").map!(to!int).array)
.array;
void main() {
writeln(matrix);
}
1. For any non-trivial matrices (with 500 lines) runs DMD 2.072.1
out of memory (2GB). Not sure if this is a known bug. Works fine
with LDC 1.0.0.
2. The EOL on the last line results in an empty row in the end.
Is there a way to overcome this?