Last active
June 3, 2020 09:07
-
-
Save zh-f/53dfe574ad9f10bbdd8c85471a8c87d8 to your computer and use it in GitHub Desktop.
Exercise Maps Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"golang.org/x/tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
counter := make(map[string]int) | |
for _, v := range strings.Fields(s) { | |
counter[v] += 1 | |
} | |
return counter | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result