dlang.org redesign -- a better code sample for landing page

via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 26 12:54:06 PST 2015


On Friday, 23 January 2015 at 13:55:04 UTC, aldanor wrote:
>     auto lines = stdin.byLine.map!(line => line.length);
>     writefln("Average line length: %.4f.", 1.0 * lines.sum / 
> lines.array.length);

This won't work; `sum` already consumes the range, so there will 
be nothing left to compute the length from.


More information about the Digitalmars-d mailing list