Skip to content

Instantly share code, notes, and snippets.

@memfrag
Last active August 29, 2015 14:04
Show Gist options
  • Save memfrag/821fe651eaf55b37ae1c to your computer and use it in GitHub Desktop.
Save memfrag/821fe651eaf55b37ae1c to your computer and use it in GitHub Desktop.
[Swift] Mean Value of a Sequence of Numbers
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