big-moving.ru/assets/vendor_plugins/ace-builds-master/demo/kitchen-sink/docs/d.d

14 lines
324 B
D
Raw Normal View History

2022-06-24 15:29:23 +05:00
#!/usr/bin/env rdmd
// Computes average line length for standard input.
import std.stdio;
void main() {
ulong lines = 0;
double sumLength = 0;
foreach (line; stdin.byLine()) {
++lines;
sumLength += line.length;
}
writeln("Average line length: ",
lines ? sumLength / lines : 0);
}