mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
11 lines
187 B
Go
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
|
|
}
|