Guest User

Untitled

a guest
Dec 12th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "golang.org/x/tour/wc"
  5. "strings"
  6. )
  7.  
  8. func WordCount(s string) map[string]int {
  9. set := strings.Fields(s)
  10. var st_map map[string]int = make(map[string]int)
  11. for i := range set {
  12. count := 0
  13. for j := range set {
  14. if set[i] == set[j] {
  15. count = count + 1
  16. }
  17. }
  18. st_map[set[i]] = count
  19. }
  20. return st_map
  21. }
  22.  
  23. func main() {
  24. wc.Test(WordCount)
  25. }
Add Comment
Please, Sign In to add comment