How to lazily filter an iterator while also applying a function to it

Oh, if the n^2 is expensive, I’d just make that decision inside of expensive() and not worry about mapping. Just filter on !isnothing (or use a sentinel for type stability) and you’re all set.

1 Like