Last active
September 25, 2018 00:47
-
-
Save jchung05/419d8dae2dd3ea4af44c93ac4729ccaf to your computer and use it in GitHub Desktop.
An attempt at the A Tour of Go Maps exercise
This file contains 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 { | |
ret := make(map[string]int) | |
words := strings.Fields(s) | |
for word := range words { | |
ret[words[word]]++ | |
} | |
return ret | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment