Created
October 23, 2015 03:56
-
-
Save mayra-cabrera/8a7d656b0eba39f3f03d to your computer and use it in GitHub Desktop.
Exercise-maps
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 ( | |
"golang.org/x/tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
array := strings.Fields(s) | |
count := make(map[string]int) | |
for i := range array{ | |
count[array[i]] = len(array[i]) | |
} | |
return count | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment