sum: use variadic functions
This commit is contained in:
parent
e905c600f3
commit
29215486db
10
sum/sum.go
10
sum/sum.go
@ -9,6 +9,12 @@ func Sum(numbers []int) int {
|
||||
return sum
|
||||
}
|
||||
|
||||
func SumAll(x []int, y []int) []int {
|
||||
return []int{Sum(x), Sum(y)}
|
||||
func SumAll(numbersToSum ...[]int) []int {
|
||||
res := make([]int, len(numbersToSum))
|
||||
|
||||
for i, numbers := range numbersToSum {
|
||||
res[i] = Sum(numbers)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user