reading from file

Stefan Koch via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 16 00:02:11 PST 2016


On Friday, 16 December 2016 at 06:47:15 UTC, KaattuPoochi wrote:
> 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?

Most likely you are using a 64bit ldc, and a 32bit dmd.
Since I am pretty sure the ldc guys have no CTFE patches.

I am working on fixing that problem.


More information about the Digitalmars-d-learn mailing list