Created
April 14, 2016 08:02
-
-
Save kkabdol/be6a6e8c2d4c96c7af975387b696d141 to your computer and use it in GitHub Desktop.
go langauge exersice
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 { | |
ret := map[string]int{} | |
split := strings.Split(s, " ") | |
for _, ss := range split { | |
_, ok := ret[ss] | |
if ok == true { | |
ret[ss]++ | |
} else { | |
ret[ss] = 1 | |
} | |
} | |
return ret | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment