logmower-shipper/vendor/github.com/montanaflynn/stats/sum.go
rasmus e45bf4739b go mod vendor
+ move k8s.io/apimachinery fork from go.work to go.mod
(and include it in vendor)
2022-11-07 00:26:05 +02:00

19 lines
271 B
Go

package stats
import "math"
// Sum adds all the numbers of a slice together
func Sum(input Float64Data) (sum float64, err error) {
if input.Len() == 0 {
return math.NaN(), EmptyInputErr
}
// Add em up
for _, n := range input {
sum += n
}
return sum, nil
}