Accumulate
Introduction
package accumulate
// Accumulate change slice content base on the converter
func Accumulate(s []string, converter func(string) string) []string {
result := s
for i, r := range s {
result[i] = converter(r)
}
return result
}
package accumulate
type Converter func(string) string
func Accumulate(in []string, cn Converter) (out []string) {
for _, s := range in {
out = append(out, cn(s))
}
return
}Point
Last updated
Was this helpful?