Skip to content

Instantly share code, notes, and snippets.

@mayra-cabrera
Created October 23, 2015 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayra-cabrera/8a7d656b0eba39f3f03d to your computer and use it in GitHub Desktop.
Save mayra-cabrera/8a7d656b0eba39f3f03d to your computer and use it in GitHub Desktop.
Exercise-maps
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