From 2c3b10da76e3699b74990f89c2d953a3ecfd9a2e Mon Sep 17 00:00:00 2001 From: superwhiskers Date: Sat, 22 Jun 2019 23:38:36 -0500 Subject: [PATCH] fix the word counter example --- examples/word_counter/word_counter.v | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/word_counter/word_counter.v b/examples/word_counter/word_counter.v index a7a7417b14..18531187a7 100644 --- a/examples/word_counter/word_counter.v +++ b/examples/word_counter/word_counter.v @@ -9,17 +9,14 @@ fn main() { else { path = os.args[1] } - lines := os.read_file_lines(path.trim_space()) + contents := os.read_file(path.trim_space()) mut m := map[string]int{} - for line in lines { - words := line.to_lower().split(' ') - for word in words { - key := filter_word(word) - if key == '' { - continue - } - m[key] = m[key] + 1// TODO m[key]++ + for word in contents.to_lower().split(' ') { + key := filter_word(word) + if key == '' { + continue } + m[key] = m[key] + 1// TODO m[key]++ } // Sort the keys mut keys := []string