Created
October 1, 2018 13:10
-
-
Save mekicha/57e5963f3e25c99c9cfdef97e6ca8ee3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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