mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix the word counter example
This commit is contained in:
parent
889d564f43
commit
2c3b10da76
@ -9,18 +9,15 @@ 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(' ')
|
|
||||||
for word in words {
|
|
||||||
key := filter_word(word)
|
key := filter_word(word)
|
||||||
if key == '' {
|
if key == '' {
|
||||||
continue
|
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
|
||||||
for e in m.entries {
|
for e in m.entries {
|
||||||
|
Loading…
Reference in New Issue
Block a user