underscore/sum.go
Ruidy 482e553263
sum (#13)
Co-authored-by: Ruidy <rnemausat@newstore.com>
2022-02-20 15:34:09 +01:00

11 lines
187 B
Go

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