以下のコードでは2通りの方法でIntの配列を作っています。 どちらの方がパフォーマンスが良いでしょうか。 let sequence = stride(from: 0, to: 1000000, by: 1) // パターンA let arrayA = sequence.map({ $0 * ($0 + 2) }).filter({ $0 % 2 == 0 }).map({ $0 + 1 }) // パターンB let lazySeq = sequence.lazy.map({ $0 * ($0 + 2) }).filter({ $0 % 2 == 0 }).map({ $0 + 1 }) let arrayB = Array(lazySeq) arrayA == arrayB // => true 答えは、パターンBの方がパフォーマンスが良いです。 この記事ではその理由を解説します。 お願