Created
August 27, 2014 06:10
-
-
Save kamatama41/723f5a1cc571af45ff7b to your computer and use it in GitHub Desktop.
My answer of "a tour of Go #41( http://go-tour-jp.appspot.com/#41 )"
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 ( | |
"strings" | |
"code.google.com/p/go-tour/wc" | |
) | |
func WordCount(s string) map[string]int { | |
countMap := make(map[string]int) | |
for _, word := range strings.Fields(s) { | |
countMap[word] = countMap[word] + 1 | |
} | |
return countMap | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment