Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created November 26, 2011 21:48
Show Gist options
  • Save jordanorelli/1396349 to your computer and use it in GitHub Desktop.
Save jordanorelli/1396349 to your computer and use it in GitHub Desktop.
exercise 43
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