Skip to content

Instantly share code, notes, and snippets.

@aesteve aesteve/maps.go
Created Jan 20, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.