let arrayFirst = [1,2,7,9] let arraySecond = [4,5,17,20]
First zip(_:_:)
them to create a sequence that acts like an array of pairs
let zipped = zip(arrayFirst, arraySecond)
Then map(_:)
over the tuples and apply the +
operator:
let result = zipped.map(+)
Together:
let result = zip(arrayFirst, arraySecond).map(+)
source share