exercise 2
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.google.com/p/go-tour/wc"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func WordCount(s string) map[string]int {
|
||||||
|
wc := make(map[string]int)
|
||||||
|
for _, v := range strings.Fields(s) {
|
||||||
|
wc[v] += 1
|
||||||
|
}
|
||||||
|
return wc
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
wc.Test(WordCount)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user