underscore/sum.go
Ruidy 3bfe1aca18
Code coverage (#15)
* 👷 adding test and push coverage

* ⬆️ use official Go 1.18 image

Co-authored-by: Ruidy <rnemausat@newstore.com>
2022-03-18 18:22:01 +01:00

11 lines
204 B
Go

package underscore
import "golang.org/x/exp/constraints"
// Sum adds elements of the slice.
func Sum[T constraints.Ordered](values []T) (sum T) {
for _, v := range values {
sum += v
}
return sum
}