blob: 453ff8cf10f63de9622068f4119db1041fed0d95 [file] [log] [blame] [raw]
// Imperative style sum over an array of integers
func imperativeSum(input: [Int]) -> Int {
var sum = 0
for value in input {
sum += value
}
return sum
}
// Functional style sum over an array of integers
func functionalSum(input: [Int]) -> Int {
return input.reduce(0, +)
}