Solution 7ae34b6188784d06a7fd50faa6872bba is fine:
func ConcurrentFrequency(strings []string) FreqMap {
results := make(chan FreqMap)
m := FreqMap{}
for _, currentString := range strings {
go func(text string) {
results <- Frequency(text)
}(currentString)
}
for range strings {
for k, v := range <-results {
m[k] += v
}
}
return m
}
but Exalysis thinks it's waiting for the goroutines to be done [most definitely my fault]:
Here is one thought for further improvement:
- It looks like you wait until all results have been received from the goroutines before starting to merge them. In fact, you can (and should) start processing as soon as you receive the first result.
Solution 7ae34b6188784d06a7fd50faa6872bba is fine:
but Exalysis thinks it's waiting for the goroutines to be done [most definitely my fault]: