Merge: Do not compile dead modules
[nit.git] / examples / rosettacode / letter_frequency.nit
1 #!/usr/bin/env nit
2 #
3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # This program is public domain
5
6 # Task: Open a text file and count the occurrences of each letter.
7 # SEE: <http://rosettacode.org/wiki/Letter_frequency>
8 #
9
10 import counter
11
12 var file = new FileReader.open("/etc/issue")
13 var counter = new Counter[Char]
14 while not file.eof do
15 var char = file.read_char
16 if char != null and char.is_letter then
17 counter.inc(char)
18 end
19 end
20
21 for char, count in counter do
22 print "{char} => {count}"
23 end