Created
July 31, 2018 22:10
-
-
Save kumarsoumya/ba79e8222a6b2c9fca895cb966103c68 to your computer and use it in GitHub Desktop.
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 { | |
words := strings.Fields(s) | |
wordCount := make(map[string]int) | |
for _, word := range words { | |
wordCount[word] = wordCount[word] + 1 | |
} | |
return wordCount | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment