30 lines
730 B
Text
30 lines
730 B
Text
use IO;
|
|
|
|
bundle Default {
|
|
class Test {
|
|
function : Main(args : String[]) ~ Nil {
|
|
freqs := CountLetters("filename.txt");
|
|
for(i := 'A'; i < 'Z'; i += 1;) {
|
|
Console->Print(i->As(Char))->Print("=>")->PrintLine(freqs[i - 'A']);
|
|
};
|
|
}
|
|
|
|
function : CountLetters(filename : String) ~ Int[] {
|
|
freqs := Int->New[26];
|
|
reader := FileReader->New(filename);
|
|
while(reader->IsEOF() <> true) {
|
|
line := reader->ReadString()->ToUpper();
|
|
each(i : line) {
|
|
ch := line->Get(i);
|
|
if(ch->IsChar()){
|
|
index := ch - 'A';
|
|
freqs[index] := freqs[index] + 1;
|
|
};
|
|
};
|
|
};
|
|
reader->Close();
|
|
|
|
return freqs;
|
|
}
|
|
}
|
|
}
|