Last active
August 29, 2015 14:04
-
-
Save memfrag/821fe651eaf55b37ae1c to your computer and use it in GitHub Desktop.
[Swift] Mean Value of a Sequence of Numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let values = [4, 8, 15, 16, 23, 42] | |
let meanValue = values.reduce(0, +) / values.count | |
// + is a operator function and we can pass it in to reduce as the function parameter. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment