service/vendor/github.com/montanaflynn/stats/sum.go

19 lines
268 B
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
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(), EmptyInput
}
// Add em up
for _, n := range input {
sum += n
}
return sum, nil
}