Created
July 14, 2013 04:52
-
-
Save MattSurabian/5993259 to your computer and use it in GitHub Desktop.
My implementation of WordCount in Go. Part of the Go tour: http://tour.golang.org/#40
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 ( | |
"code.google.com/p/go-tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
words := strings.Fields(s) | |
wordCountMap := make(map[string]int) | |
for _,word := range words{ | |
wordCountMap[word]++ | |
} | |
return wordCountMap | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
vishuvenu
commented
Aug 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment