Created
May 7, 2013 04:01
-
-
Save timbogit/5530175 to your computer and use it in GitHub Desktop.
Maps exercise in Go tour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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