Skip to content

Instantly share code, notes, and snippets.

@timbogit
Created May 7, 2013 04:01
Show Gist options
  • Save timbogit/5530175 to your computer and use it in GitHub Desktop.
Save timbogit/5530175 to your computer and use it in GitHub Desktop.
Maps exercise in Go tour
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
res := make(map[string]int)
var words []string = strings.Fields(s)
for _, word := range words {
res[word] += 1
}
return res
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment