Created
July 13, 2012 21:44
-
-
Save freeformz/3107723 to your computer and use it in GitHub Desktop.
My GoTour Exercise #45 (http://tour.golang.org/#45) solution
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 ( | |
"strings" | |
"code.google.com/p/go-tour/wc" | |
) | |
// Maybe strings.Fields is cheating? | |
func WordCount(s string) map[string]int { | |
wc := make(map[string]int) | |
for _, word := range strings.Fields(s) { | |
wc[word] += 1 | |
} | |
return wc | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment