blob: 3e338bd1f39f4f410a6d7e80ee6c707fcce492a5 (
plain)
1
2
3
4
5
6
7
8
9
|
package moe.nea.notenoughupdates.util
fun <T : Any> T.iterate(iterator: (T) -> T?): Sequence<T> = sequence {
var x: T? = this@iterate
while (x != null) {
yield(x)
x = iterator(x)
}
}
|