Skip to content

Instantly share code, notes, and snippets.

@sugilog
Created January 3, 2015 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sugilog/7c30b8d30fe62a2bda01 to your computer and use it in GitHub Desktop.
Save sugilog/7c30b8d30fe62a2bda01 to your computer and use it in GitHub Desktop.
mapの演習
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
counts := map[string]int{}
for _, word := range strings.Fields( s ) {
counts[ word ]++
}
return counts
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment