blob: 8877787364e4bd7f751c2ca8b096335f52d29c00 [file] [log] [blame] [raw]
// Imperative style array of maximum values per index
func imperativeMaxArray(x: [Int], y: [Int]) -> [Int] {
var maxima: [Int] = []
let count = min(x.count, y.count)
for index in 0..<count {
maxima.append(max(x[index], y[index]))
}
return maxima
}
// Functional style array of maximum values per index
func functionalMaxArray(x: [Int], y: [Int]) -> [Int] {
return zip(x, y).map(max)
}