Last active
October 22, 2017 03:57
-
-
Save phigasui/2d2fc31c519c39f8b067c608ac581cd3 to your computer and use it in GitHub Desktop.
A Tour of Go: https://go-tour-jp.appspot.com/moretypes/23
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 { | |
words := make(map[string]int) | |
for _, word := range strings.Fields(s) { | |
words[word] += 1 | |
} | |
return words | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment