Browse Source

optimized by not creating a new array

looking at other submitted examples by the exercism community, there are other ways to go about this.
master
Blaine Motsinger 1 year ago
parent
commit
96e721fb29
1 changed files with 3 additions and 5 deletions
  1. 3
    5
      go/accumulate/accumulate.go

+ 3
- 5
go/accumulate/accumulate.go View File

@@ -1,13 +1,11 @@
// Package accumulate - exercise for the exercism.io go track
package accumulate

// Accumulate performs a given operation on an array of strings, then returns the new array of strings
// Accumulate performs a given operation on an array of strings, then returns the updated array of strings
func Accumulate(strings []string, converter func(string) string) []string {
stringsProcessed := make([]string, len(strings))

for n := 0; n < len(strings); n++ {
stringsProcessed[n] = converter(strings[n])
strings[n] = converter(strings[n])
}

return stringsProcessed
return strings
}

Loading…
Cancel
Save