diff options
author | nea <romangraef@gmail.com> | 2022-07-30 04:55:04 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-07-30 04:55:04 +0200 |
commit | b9455467863f194accf30a89b2c2998822f2c105 (patch) | |
tree | 5fb27bf4b8b8b00c7ed7ce414858733a595d3847 /src/main/kotlin/moe/nea/notenoughupdates/util | |
parent | e45378fd6b61a5871c306ca8439c8ee3d7dec456 (diff) | |
download | firmament-b9455467863f194accf30a89b2c2998822f2c105.tar.gz firmament-b9455467863f194accf30a89b2c2998822f2c105.tar.bz2 firmament-b9455467863f194accf30a89b2c2998822f2c105.zip |
repo downloading
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/util')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/util/SequenceUtil.kt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/SequenceUtil.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/SequenceUtil.kt new file mode 100644 index 0000000..3e338bd --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/util/SequenceUtil.kt @@ -0,0 +1,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) + } +} |