mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 10:36:43 +00:00
* 👷 adding test and push coverage * ⬆️ use official Go 1.18 image Co-authored-by: Ruidy <rnemausat@newstore.com>
11 lines
204 B
Go
11 lines
204 B
Go
package underscore
|
|
|
|
import "golang.org/x/exp/constraints"
|
|
|
|
// Sum adds elements of the slice.
|
|
func Sum[T constraints.Ordered](values []T) (sum T) {
|
|
for _, v := range values {
|
|
sum += v
|
|
}
|
|
return sum
|
|
}
|