21 lines
312 B
Go
21 lines
312 B
Go
|
package main
|
||
|
|
||
|
// Exercise: https://go.dev/tour/moretypes/23
|
||
|
|
||
|
import (
|
||
|
//"golang.org/x/tour/wc" // Not valid in local!
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func WordCount(s string) map[string]int {
|
||
|
m := make(map[string]int)
|
||
|
for _, val := range strings.Fields(s) {
|
||
|
m[val] += 1
|
||
|
}
|
||
|
return m
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
// wc.Test(WordCount)
|
||
|
}
|