Created
October 25, 2016 15:58
-
-
Save ggirtsou/09425146103d940011190c4471aa2f53 to your computer and use it in GitHub Desktop.
Solution to https://tour.golang.org/moretypes/23
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 { | |
var m = map[string]int{} | |
words := strings.Fields(s) | |
for _, word := range words { | |
m[word]++ | |
} | |
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