mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: format most examples and tutorials, add them to v test-cleancode
(#9826)
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved.
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
import os
|
||||
|
||||
fn main() {
|
||||
@ -9,15 +8,14 @@ fn main() {
|
||||
if os.args.len != 2 {
|
||||
println('usage: word_counter [text_file]')
|
||||
println('using $path')
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
path = os.args[1]
|
||||
}
|
||||
contents := os.read_file(path.trim_space()) or {
|
||||
println('failed to open $path')
|
||||
return
|
||||
}
|
||||
mut m := map[string]int
|
||||
mut m := map[string]int{}
|
||||
for word in extract_words(contents) {
|
||||
m[word]++
|
||||
}
|
||||
@ -37,8 +35,7 @@ fn extract_words(contents string) []string {
|
||||
for space_splitted in contents.to_lower().split(' ') {
|
||||
if space_splitted.contains('\n') {
|
||||
splitted << space_splitted.split('\n')
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
splitted << space_splitted
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user