org.cqfn.diktat.ruleset.utils.SequenceUtils.kt Maven / Gradle / Ivy
/**
* Utility methods to work with sequences
*/
package org.cqfn.diktat.ruleset.utils
/**
* @param pred a predicate
* @return filtered sequence
*/
fun Sequence.takeWhileInclusive(pred: (T) -> Boolean): Sequence {
var shouldContinue = true
return takeWhile {
val result = shouldContinue
shouldContinue = pred(it)
result
}
}