Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,8 +1,23 @@
|
|||
import tango.io.Console;
|
||||
import tango.text.stream.LineIterator;
|
||||
void main() {
|
||||
import std.stdio;
|
||||
|
||||
void main (char[][] args) {
|
||||
foreach (line; new LineIterator!(char)(Cin.input)) {
|
||||
// do something with each line
|
||||
immutable fileName = "input_loop1.d";
|
||||
|
||||
foreach (const line; fileName.File.byLine) {
|
||||
pragma(msg, typeof(line)); // Prints: const(char[])
|
||||
// line is a transient slice, so if you need to
|
||||
// retain it for later use, you have to .dup or .idup it.
|
||||
line.writeln; // Do something with each line.
|
||||
}
|
||||
|
||||
// Keeping the line terminators:
|
||||
foreach (const line; fileName.File.byLine(KeepTerminator.yes)) {
|
||||
// line is a transient slice.
|
||||
line.writeln;
|
||||
}
|
||||
|
||||
foreach (const string line; fileName.File.lines) {
|
||||
// line is a transient slice.
|
||||
line.writeln;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import tango.io.Console;
|
||||
import tango.text.stream.SimpleIterator;
|
||||
import tango.text.stream.LineIterator;
|
||||
|
||||
void main (char[][] args) {
|
||||
foreach (word; new SimpleIterator!(char)(" ", Cin.input)) {
|
||||
// do something with each word
|
||||
foreach (line; new LineIterator!(char)(Cin.input)) {
|
||||
// do something with each line
|
||||
}
|
||||
}
|
||||
|
|
|
|||
8
Task/Input-loop/D/input-loop-3.d
Normal file
8
Task/Input-loop/D/input-loop-3.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import tango.io.Console;
|
||||
import tango.text.stream.SimpleIterator;
|
||||
|
||||
void main (char[][] args) {
|
||||
foreach (word; new SimpleIterator!(char)(" ", Cin.input)) {
|
||||
// do something with each word
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue