Skip to content

Instantly share code, notes, and snippets.

@mekicha
Created October 1, 2018 13:10
Show Gist options
  • Save mekicha/57e5963f3e25c99c9cfdef97e6ca8ee3 to your computer and use it in GitHub Desktop.
Save mekicha/57e5963f3e25c99c9cfdef97e6ca8ee3 to your computer and use it in GitHub Desktop.
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
list := strings.Fields(s)
m := make(map[string]int)
for _, value := range list {
m[value] += 1
}
return m
}
// taken from https://tour.golang.org/moretypes/23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment