take While
Returns a sequence containing first elements satisfying the given predicate.
The operation is intermediate and stateless.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val chars = ('a'..'z').toList()
assertPrints(chars.take(3), "[a, b, c]")
assertPrints(chars.takeWhile { it < 'f' }, "[a, b, c, d, e]")
assertPrints(chars.takeLast(2), "[y, z]")
assertPrints(chars.takeLastWhile { it > 'w' }, "[x, y, z]")
//sampleEnd
}