diff options
author | Adrian Kummerlaender | 2017-04-21 12:56:34 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-04-21 13:00:34 +0200 |
commit | 22c78d20992967e24ec8c8cf5adaf7466d3d0fd7 (patch) | |
tree | c763fa998ba1599ccf3e968abfeebb7227e7f7a7 /source | |
parent | f1fc6d8fd21b0bfd302e1e7db01b8d500fb37073 (diff) | |
download | slang-22c78d20992967e24ec8c8cf5adaf7466d3d0fd7.tar slang-22c78d20992967e24ec8c8cf5adaf7466d3d0fd7.tar.gz slang-22c78d20992967e24ec8c8cf5adaf7466d3d0fd7.tar.bz2 slang-22c78d20992967e24ec8c8cf5adaf7466d3d0fd7.tar.lz slang-22c78d20992967e24ec8c8cf5adaf7466d3d0fd7.tar.xz slang-22c78d20992967e24ec8c8cf5adaf7466d3d0fd7.tar.zst slang-22c78d20992967e24ec8c8cf5adaf7466d3d0fd7.zip |
Unify file / stdin input processing
Diffstat (limited to 'source')
-rw-r--r-- | source/app.d | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/app.d b/source/app.d index dd7be6d..b9f68c4 100644 --- a/source/app.d +++ b/source/app.d @@ -1,23 +1,24 @@ +import std.conv : to; import std.string : split; import std.range : dropOne; import std.algorithm : map, each; -import std.stdio : stdin, File, lines; +import std.stdio : stdin, File; static import machine; +void process(string line) { + line.split.each!(machine.process); +} + void process(ref File file) { - foreach ( string line; lines(file) ) { - line.split.each!(machine.process); - } + file.byLine.map!(to!string).each!process; } void main(string[] args) { args .dropOne - .map!(File) + .map!File .each!((File file) => file.process); - while ( !stdin.eof ) { - stdin.readln.split.each!(machine.process); - } + stdin.process; } |