Yes, that works. I also tried what John Colvin suggested (.byLine(KeepTerminator.no, std.ascii.newline) and that works too. Is it true that both of those are better than adding chomp because it would be one less time through the pipeline?

Learned several new things today! Thanks again!

On Friday, 1 May 2015 at 15:03:33 UTC, Ilya Yaroshenko wrote:
On Friday, 1 May 2015 at 14:01:38 UTC, Anonymous wrote:
This is great, thank you.

I couldn't get the example in the introduction to work without adding .map!(chomp) to the pipeline:

auto sample = File("10numbers.txt")
       .byLine
       .takeExactly(10)
       .map!(chomp)
        .map!(to!double)
       .tee!((x){mean += x;})
       .array;

Without that, I got an error converting to a double (my file had '\r' after each number)

On Friday, 1 May 2015 at 08:18:10 UTC, Ilya Yaroshenko wrote:

http://d.readthedocs.org

I hope this examples will be useful for students.

Ilya

`parse` should works with whitespace after number:

        auto sample = File("10numbers.txt")
                .byLine
                .takeExactly(10)
                .map!(line => parse!double(line))
                .tee!((x){mean += x;})
                .array;

Reply via email to