gizak/termui · utils.go
go logo
func SumFloat64Slice(data []float64) float64 {
	sum := 0.0
	for _, v := range data {
		sum += v
	}
	return sum
}
Similar code snippets
1.
GaryBoone/GoStats · stats.go
Match rating: 78.25% · See similar code snippets
go logo
func StatsSum(data []float64) (sum float64) {
	for _, v := range data {
		sum += v
	}
	return
}
2.
montanaflynn/stats · sum.go
Match rating: 73.69% · See similar code snippets
go logo
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
}
3.
dynport/dgtk · map.go
Match rating: 70.14% · See similar code snippets
go logo
func (m Map) Sum() (sum int) {
	for _, v := range m {
		sum += v.Value
	}
	return sum

}
4.
RichardKnop/machinery · tasks.go
Match rating: 69.63% · See similar code snippets
go logo
func SumFloats(numbers []float64) (float64, error) {
	var sum float64
	for _, num := range numbers {
		sum += num
	}
	return sum, nil
}
5.
golang/tour · channels.go
Match rating: 68.41% · See similar code snippets
go logo
func sum(s []int, c chan int) {
	sum := 0
	for _, v := range s {
		sum += v
	}
	c <- sum // send sum to c
}
6.
grokify/gotilla · slicefloat64.go
Match rating: 68.28% · See similar code snippets
go logo
func (sf64 *SliceFloat64) Sum() (float64, error) {
	if len(sf64.Elements) == 0 {
		return 0, errors.New("List is empty")
	}
	sum := float64(0)
	for _, num := range sf64.Elements {
		sum += num
	}
	return sum, nil
}
7.
lon9/mat · matrix.go
Match rating: 68.2% · See similar code snippets
go logo
func SumVec(v []float32) float32 {
	sum := float32(0.0)
	for _, e := range v {
		sum += e
	}
	return sum
}
8.
decred/dcrdata · charts.go
Match rating: 67.53% · See similar code snippets
go logo
func (data ChartFloats) Sum(s, e int) (sum float64) {
	if e <= s {
		return 0
	}
	for _, v := range data[s:e] {
		sum += v
	}
	return
}
9.
cdipaolo/goml · kmeans.go
Match rating: 67.4% · See similar code snippets
go logo
func diff(u, v []float64) float64 {
	var sum float64
	for i := range u {
		sum += (u[i] - v[i]) * (u[i] - v[i])
	}

	return sum
}
10.
thoas/go-funk · typesafe.go
Match rating: 67.32% · See similar code snippets
go logo
func SumFloat32(s []float32) (sum float32) {
	for _, v := range s {
		sum += v
	}
	return
}