On Friday, 2 August 2013 at 17:03:44 UTC, Justin Whear wrote:
On Fri, 02 Aug 2013 18:59:12 +0200, Jonathan A Dunlap wrote:

The example:
http://www.drdobbs.com/architecture-and-design/component-programming-in-
d/240008321?pgno=4

import std.stdio;
import std.array;
import std.algorithm;

     void main() {
stdin.byLine(KeepTerminator.yes) // 1 map!(a => a.idup). // 2 array. // 3
         sort.                               // 4 copy(
                      // 5
             stdout.lockingTextWriter());    // 6
     }

I don't understand what happens to the output. On windows, I can keep entering lines but no output gets displayed. Also, can someone explain a
bit more about lockingTextWriter?

Thanks!

1) The example has a typo; there should be a '.' between the byLine call
and the array call.

void main() {
  stdin.byLine(KeepTerminator.yes)   // 1
.map!(a => a.idup) // 2 '.' was missing start of this line
    .array                           // 3
    .sort                            // 4
    .copy(                           // 5
        stdout.lockingTextWriter()); // 6
}


2) The example collects all input before writing anything (so that it can sort). Hit your end-of-file character (Ctrl-D) for me to end the input. Or direct a file into the process' stdin (not sure how to do this on
Windows, it's been so long).

On Windows you send EOF by using the Ctrl-Z key sequence.

Reply via email to