Created
November 26, 2011 21:48
-
-
Save jordanorelli/1396349 to your computer and use it in GitHub Desktop.
exercise 43
This file contains hidden or 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 ( | |
"go-tour.googlecode.com/hg/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
fields := strings.Fields(s) | |
counts := make(map[string]int) | |
for i := range fields { | |
counts[fields[i]] += 1 | |
} | |
return counts | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment