mirror of
https://github.com/iLoveElysia/openbilibili.git
synced 2026-03-14 05:46:26 -05:00
19 lines
268 B
Go
19 lines
268 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(), EmptyInput
|
|
}
|
|
|
|
// Add em up
|
|
for _, n := range input {
|
|
sum += n
|
|
}
|
|
|
|
return sum, nil
|
|
}
|