Skip to content

Instantly share code, notes, and snippets.

@suzuken
Created March 8, 2014 06:39
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 suzuken/9426382 to your computer and use it in GitHub Desktop.
Save suzuken/9426382 to your computer and use it in GitHub Desktop.
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
ret := make(map[string]int)
words := strings.Fields(s)
for i:=0; i < len(words); i++ {
ret[words[i]] += 1
}
return ret
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment