On Thursday, 18 September 2014 at 11:13:36 UTC, Marc Schütz wrote:
On Thursday, 18 September 2014 at 09:21:17 UTC, krzaq wrote:
That's not what I wanted. Maybe I should explain instead of
expecting you to divine my intentions, though :) I am trying
to rewrite the following program in D--making it more elegant:
http://melpon.org/wandbox/permlink/ff42FoyKgqJK60sm
As you can see, I can have one input line consisting of n
words and then n integers and I can read from it easily. My
question whether stdin.byLine allows me to do this remains
unanswered (or I failed to understand the answer), although I
am not hopeful.
You should be able to use `std.algorithm.take` to read exactly
5 integers. However, in order to read up to the first empty
line, for example, the input would have to be a forward range
(= "rewindable"), which stdin.byLine of course is not. Maybe
you could constructor a wrapper range that caches input lines
as necessary.
Okay, I think I'll simply skip this for now.
I hoped that there would be a way of reading stdin composable
with std.algorithms, as is the case in C++.
I guess this works for now http://dpaste.dzfl.pl/6801615160e3
I have a follow-up question: why does zip not accept an array?