aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/app.d23
1 files changed, 17 insertions, 6 deletions
diff --git a/source/app.d b/source/app.d
index 4e7b546..dd7be6d 100644
--- a/source/app.d
+++ b/source/app.d
@@ -1,12 +1,23 @@
-import std.string : split;
-import std.stdio : stdin, readln, writeln;
+import std.string : split;
+import std.range : dropOne;
+import std.algorithm : map, each;
+import std.stdio : stdin, File, lines;
static import machine;
-void main() {
+void process(ref File file) {
+ foreach ( string line; lines(file) ) {
+ line.split.each!(machine.process);
+ }
+}
+
+void main(string[] args) {
+ args
+ .dropOne
+ .map!(File)
+ .each!((File file) => file.process);
+
while ( !stdin.eof ) {
- foreach ( token; stdin.readln.split ) {
- machine.process(token);
- }
+ stdin.readln.split.each!(machine.process);
}
}