Skip to content

Instantly share code, notes, and snippets.

@getaaron
Created November 6, 2015 01:43
Show Gist options
  • Save getaaron/b8263db226ae293efae7 to your computer and use it in GitHub Desktop.
Save getaaron/b8263db226ae293efae7 to your computer and use it in GitHub Desktop.
func mean(numbers: [Double]) -> Double {
return numbers.reduce(0, combine: +) / Double(numbers.count)
}
func mean(numbers: Double...) -> Double {
return mean(numbers)
}
mean(1, 2, 3, 4, 5) // 3
mean([1,2,3,4,5]) // 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment