Skip to content

Instantly share code, notes, and snippets.

@shockalotti
Created May 27, 2014 07:26
Show Gist options
  • Save shockalotti/54b0c94e71df577104e7 to your computer and use it in GitHub Desktop.
Save shockalotti/54b0c94e71df577104e7 to your computer and use it in GitHub Desktop.
Go Golang - average function
package main
import "fmt"
func average(xs[]float64)float64 {
total:=0.0
for _,v:=range xs {
total +=v
}
return total/float64(len(xs))
}
func main() {
xs:=[]float64{98,93,77,82,83}
fmt.Println(average(xs))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment