RosettaCodeData/Task/Letter-frequency/Draco/letter-frequency.draco
2023-07-01 13:44:08 -04:00

31 lines
715 B
Text

proc nonrec main() void:
file() infile;
[256] char linebuf;
[256] word count;
*char line;
char c;
byte i;
word n;
channel input text filech;
channel input text linech;
for i from 0 upto 255 do count[i] := 0 od;
line := &linebuf[0];
open(filech, infile, "unixdict.txt");
while readln(filech; line) do
open(linech, line);
while read(linech; c) do
i := pretend(c, byte);
count[i] := count[i] + 1
od;
close(linech)
od;
close(filech);
for c from 'A' upto 'Z' do
i := pretend(c, byte);
n := count[i] + count[i | 32];
writeln(c, pretend(i | 32, char), ": ", n:5)
od
corp