PHP » GoLang |
login |
register |
about
|
array_count_valuesarray_count_values[code=golang] func ArrayCountValues(s []interface{}) map[interface{}]uint { r := make(map[interface{}]uint) for _, v := range s { if c, ok := r[v]; ok { r[v] = c + 1 } else { r[v] = 1 } } return r } [/code] |