Created
February 6, 2016 05:13
-
-
Save haranicle/504b86b679c50909f889 to your computer and use it in GitHub Desktop.
letで再帰 #CodePiece #cswift
This file contains hidden or 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 sum: ([Int]) -> Int | |
sum = { values in | |
if values.isEmpty { | |
return 0 | |
} | |
else { | |
return values.first! + sum(Array(values.dropFirst())) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment