I have the following program D, which should group the input lines in the size of 3 groups.
import std.stdio;
import std.range;
import std.array;
void main()
{
while (!stdin.eof) {
auto currentBlock = array(take(stdin.byLineCopy, 3));
foreach (i, e; currentBlock) {
writefln("%d) %s", i, e);
}
}
}
and taking into account the following input
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Pluto
it outputs the result.
0) Mercury
1) Venus
2) Earth
0) Jupiter
1) Saturn
2) Uranus
0) Pluto
skipping the line at the border on every iteration (Mars and Neptune are not displayed). What am I doing wrong?
source
share