Source

go-play / avg64.go

package main

import (
	"fmt"
)

func avg64(items []float64) float64 {
	var avg float64

	avg = 0
	for _, v := range items {
		avg += v
	}
	return avg / float64(len(items))
}


func main() {
	items := []float64{1, 2, 3, 4}

	fmt.Println(avg64(items))
}