Skip to content

Instantly share code, notes, and snippets.

@aesteve
Created January 20, 2016 21:16
Show Gist options
  • Save aesteve/2ce65f0e89d512122d4c to your computer and use it in GitHub Desktop.
Save aesteve/2ce65f0e89d512122d4c to your computer and use it in GitHub Desktop.
Go Map exercise
package main
import (
"golang.org/x/tour/wc";
"strings";
)
func WordCount(s string) map[string]int {
count := make(map[string]int)
words := strings.Fields(s)
for _, word := range words {
count[word]++
}
return count
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment