Created
July 26, 2020 11:19
-
-
Save DaisukeNagata/2224a2ad7ced15508c587c992abee9da to your computer and use it in GitHub Desktop.
Swift_Total_ Average
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 array = [1, 2, 3, 4, 5] | |
let total = array.map { $0 }.reduce(.zero, +) | |
let average = array.map { $0 }.reduce(.zero, +)/array.count | |
print(total) | |
print(average) |
Author
DaisukeNagata
commented
Jul 26, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment