I believe you could avoid paying the cost of filte...
# getting-started
k
I believe you could avoid paying the cost of filtering the whole list by doing
list.asSequence().filter { it % 2 == 0 }.take(2).toList()
. Then the filter would be lazily evaluated and the
take
operation would terminate the sequence once 2 elements are emitted