4 ms·
In Swift: (0...100) .filter { $0 % 2 == 0 } .map { $0 * 2 } Will pass through the sequence multiple times, yes. But to avoid it it's as eas
by oisdk 11y ago
In Swift:
(0...100)
.filter { $0 % 2 == 0 }
.map { $0 * 2 }
Will pass through the sequence multiple times, yes. But to avoid it it's as easy as:
(0...100)
.lazy
.filter { $0 % 2 == 0 }
.map { $0 * 2 }