RosettaCodeData/Task/Letter-frequency/D/letter-frequency.d

12 lines
319 B
D
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
void main() {
2015-02-20 00:35:01 -05:00
import std.stdio, std.ascii, std.algorithm, std.range;
2013-10-27 22:24:23 +00:00
uint[26] frequency;
2013-04-10 21:29:02 -07:00
2013-10-27 22:24:23 +00:00
foreach (const buffer; "unixdict.txt".File.byChunk(2 ^^ 15))
foreach (immutable c; buffer.filter!isAlpha)
frequency[c.toLower - 'a']++;
2013-04-10 21:29:02 -07:00
2013-10-27 22:24:23 +00:00
writefln("%(%(%s, %),\n%)", frequency[].chunks(10));
2013-04-10 21:29:02 -07:00
}