fix the word counter example

pull/417/head
superwhiskers 2019-06-22 23:38:36 -05:00 committed by Alex Medvednikov
parent 889d564f43
commit 2c3b10da76
1 changed files with 6 additions and 9 deletions

View File

@ -9,17 +9,14 @@ fn main() {
else { else {
path = os.args[1] path = os.args[1]
} }
lines := os.read_file_lines(path.trim_space()) contents := os.read_file(path.trim_space())
mut m := map[string]int{} mut m := map[string]int{}
for line in lines { for word in contents.to_lower().split(' ') {
words := line.to_lower().split(' ') key := filter_word(word)
for word in words { if key == '' {
key := filter_word(word) continue
if key == '' {
continue
}
m[key] = m[key] + 1// TODO m[key]++
} }
m[key] = m[key] + 1// TODO m[key]++
} }
// Sort the keys // Sort the keys
mut keys := []string mut keys := []string