Lazy Filters and Maps
Simply wrapping
items
in alazy()
call will convert ourSequence
into aLazySequence
. This gives us the performance benefits of the more iterative-style approach with the benefits of the semantically broken out operations.
map and filter produce copies which are likely cause of slowdown. lazy().map and filter should be as fast as loops.
I believe you, but I’m looking at map vs for-loop code in the very moment where loop is many times faster than lazy map.