Skip to content

Instantly share code, notes, and snippets.

@cuckookernel
Created August 3, 2019 17:57
Show Gist options
  • Save cuckookernel/5fc445585c469644b1fcd51488b08d28 to your computer and use it in GitHub Desktop.
Save cuckookernel/5fc445585c469644b1fcd51488b08d28 to your computer and use it in GitHub Desktop.
extension Array where Element == Double {
func mean() -> Double {
if self.count == 0 { return Double.nan }
var ret = 0.0
for x in ret {
ret += x
}
return ret / self.count
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment