This appears to work ... at least, no exception:
auto sm = File(fn).byLine(KeepTerminator.no)
.map!a.chomp()
.map!a.idup()
.map!(to!double)
.map!a.log10()
.sum();
writeln(sum=,sm);
This also works.
auto sm = File(fn).byLineCopy()
.map!a.chomp()
.map!(to!double)
.map!a.log10()
.sum();
writeln(sum=,sm);
I tried to create a working example from the std.parallelism
taskPool.map code, and it throws with empty strings with length 1
being passed to to!double. Anyone have a working example? I'm
building on Windows with 2.067.1 dmd.
import std.parallelism;
import std.algorithm;
import std.stdio;
and, finally, this works using the taskPool.map, as in the
std.parallelism example. So, the trick appears to be that the
call to chomp is needed.
auto lineRange = File(fn).byLineCopy();
auto chomped = std.algorithm.map!a.chomp(lineRange);
auto nums =
Unfortunately, this is not a very good example for
std.parallelism, since the measured times are better using the
std.algorithm.map calls. I know from past experience that
std.parallelism routines can work well when the work is spread
out correctly, so this example could be improved.
This is