From e99ca5c8fa7857c754111989f5a99236b4429fc8 Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Thu, 2 Aug 2012 14:45:27 -0600 Subject: [PATCH] exercise 2 --- exercise01/go.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 exercise01/go.go diff --git a/exercise01/go.go b/exercise01/go.go new file mode 100644 index 0000000..4f47098 --- /dev/null +++ b/exercise01/go.go @@ -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) +}