Skip to content

Instantly share code, notes, and snippets.

@tmtk75
Created July 9, 2013 06:50
Show Gist options
  • Select an option

  • Save tmtk75/5955209 to your computer and use it in GitHub Desktop.

Select an option

Save tmtk75/5955209 to your computer and use it in GitHub Desktop.
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
m := make(map[string]int)
for _, a := range(strings.Fields(s)) {
m[a] += 1
}
return m
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment