word count with go
package main | |
import ( | |
"code.google.com/p/go-tour/wc" | |
"strings" | |
) | |
var m map[string]int | |
func WordCount(s string) map[string]int { | |
sub_string := strings.Fields(s) | |
m = make(map[string]int) | |
for i := 0 ; i < len(sub_string); i++ { | |
m[sub_string[i]]++ | |
} | |
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