Side by Side Diff: gotour/solutions/maps.go
Issue 6589070 :
code review 6589070: go-tour: add copyright notices (Closed)
Patch Set: diff -r bb8e3b14b929 https://code.google.com/p/go-tour
Use n/p to move between diff chunks;
N/P to move between comments.
Please Sign in to add in-line comments.
Jump to:
gotour/solutions/binarytrees.go
gotour/solutions/complexcube.go
gotour/solutions/errors.go
gotour/solutions/fib.go
gotour/solutions/image.go
gotour/solutions/loops.go
gotour/solutions/maps.go
gotour/solutions/rot13.go
gotour/solutions/slices.go
gotour/solutions/webcrawler.go
OLD NEW
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
1 package main 5 package main
2 6
3 import ( 7 import (
4 "strings" 8 "strings"
5 "tour/wc" 9 "tour/wc"
6 ) 10 )
7 11
8 func WordCount(s string) map[string]int { 12 func WordCount(s string) map[string]int {
9 m := make(map[string]int) 13 m := make(map[string]int)
10 for _, f := range strings.Fields(s) { 14 for _, f := range strings.Fields(s) {
11 m[f]++ 15 m[f]++
12 } 16 }
13 return m 17 return m
14 } 18 }
15 19
16 func main() { 20 func main() {
17 wc.Test(WordCount) 21 wc.Test(WordCount)
18 } 22 }
OLD NEW