Maps exercise!

This commit is contained in:
Dan Buch 2012-08-25 22:18:48 -04:00
parent 892960c712
commit e48569cc70

View File

@ -0,0 +1,19 @@
package main
import (
"strings"
"code.google.com/p/go-tour/wc"
)
func WordCount(s string) map[string]int {
counts := make(map[string]int)
words := strings.Fields(s)
for _, word := range words {
counts[word]++
}
return counts
}
func main() {
wc.Test(WordCount)
}