Formatted input from text file
bearophile
bearophileHUGS at lycos.com
Mon Jun 18 05:23:32 PDT 2012
IK:
> Question: how to read that grid from a text file?
I don't know the cause of your problem. While investigating it I
have filed another bug:
http://d.puremagic.com/issues/show_bug.cgi?id=8260
In the meantime this (a bit scary) code solves your reading
problem:
import std.stdio, std.algorithm, std.range, std.conv;
void main() {
const grid = File("table.txt")
.byLine().map!(r => std.algorithm.splitter(r)
.map!(to!int)()
.array())()
.array();
writeln(grid);
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list