Skip to content

Instantly share code, notes, and snippets.

@karlmutch
Created July 14, 2015 22:18
Show Gist options
  • Save karlmutch/7696c808746571697b88 to your computer and use it in GitHub Desktop.
Save karlmutch/7696c808746571697b88 to your computer and use it in GitHub Desktop.
func WordCount(s string) map[string]int {
wcMap := make(map[string]int)
for _,word := range strings.Fields(s) {
if _,ok := wcMap[word] ; ok {
wcMap[word]++
} else {
wcMap[word] = 1
}
}
return wcMap
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment