sum: use variadic functions

This commit is contained in:
vinchent 2024-09-10 21:38:18 +02:00
parent e905c600f3
commit 29215486db

View File

@ -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
}