LazySequence

Here’s the code if you want to experiment with it:

import Foundation

(1...10_000)
    .lazy
    .map { $0 * $0 } // executed 15 times
    .filter { $0.isMultiple(of: 5) } // executed 15 times
    .first (where: { $0 > 100 })
Previous
Previous

ResultBuilder + local constant

Next
Next

generic extensions