On 06/11/2017 03:00 PM, helxi wrote:
I would also be
really humbled if you demonstrate a faster approach of achieving the
goal of the program :) (without explicitly using loops and conditions)
Do you have a reason to believe that your version is slow? I don't see
why it would be.
On Sunday, 11 June 2017 at 12:49:51 UTC, Cym13 wrote:
print each line
byLine doesn't reall all input at once. Using byline and take
you are effectively reading only the right amount of lines and
not reading the rest. You already have what you want, what
makes you think the contrary?
Oh it w
On Sunday, 11 June 2017 at 12:44:05 UTC, helxi wrote:
On Sunday, 11 June 2017 at 06:28:18 UTC, Stanislav Blinov wrote:
On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote:
[...]
You need only the nth line? Then you'd need to `drop` the
preceding ones:
void main(string[] args) {
import
On Sunday, 11 June 2017 at 06:28:18 UTC, Stanislav Blinov wrote:
On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote:
I was writing a program that reads and prints the first nth
lines to the stdout:
import std.stdio;
void main(string[] args)
{
import std.algorithm, std.range;
import
On Sunday, 11 June 2017 at 08:33:16 UTC, Cym13 wrote:
On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote:
[...]
Ok, if I read you right you are writing to stdin and want first
to print the first args[1] lines, then to do other things with
the other lines of stdin.
[...]
Meh... I just n
On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote:
I was writing a program that reads and prints the first nth
lines to the stdout:
import std.stdio;
void main(string[] args)
{
import std.algorithm, std.range;
import std.conv;
stdin.byLine.take(args[1].to!ulong).each!writeln;
}
On Sunday, June 11, 2017 06:28:18 Stanislav Blinov via Digitalmars-d-learn
wrote:
> On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote:
> > I was writing a program that reads and prints the first nth
> > lines to the stdout:
> >
> > import std.stdio;
> >
> > void main(string[] args)
> > {
> >
>
On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote:
I was writing a program that reads and prints the first nth
lines to the stdout:
import std.stdio;
void main(string[] args)
{
import std.algorithm, std.range;
import std.conv;
stdin.byLine.take(args[1].to!ulong).each!writeln;
}
I was writing a program that reads and prints the first nth lines
to the stdout:
import std.stdio;
void main(string[] args)
{
import std.algorithm, std.range;
import std.conv;
stdin.byLine.take(args[1].to!ulong).each!writeln;
}
As far as I understand the stdin.byLine.take(args[1].t