Re: byLine(n)?

2017-06-11 Thread ag0aep6g via Digitalmars-d-learn
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.

Re: byLine(n)?

2017-06-11 Thread helxi via Digitalmars-d-learn
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

Re: byLine(n)?

2017-06-11 Thread Cym13 via Digitalmars-d-learn
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) {

Re: byLine(n)?

2017-06-11 Thread helxi via Digitalmars-d-learn
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

Re: byLine(n)?

2017-06-11 Thread Cym13 via Digitalmars-d-learn
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

Re: byLine(n)?

2017-06-11 Thread Cym13 via Digitalmars-d-learn
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; }

Re: byLine(n)?

2017-06-11 Thread Jonathan M Davis via Digitalmars-d-learn
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) > > { > > >

Re: byLine(n)?

2017-06-11 Thread Stanislav Blinov via Digitalmars-d-learn
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; }