Join Slack
Powered by
I believe you could avoid paying the cost of filte...
# getting-started
k
kevinmost
05/15/2017, 2:52 PM
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
6
Views
Open in Slack
Previous
Next