aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/util
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-07-30 04:55:04 +0200
committernea <romangraef@gmail.com>2022-07-30 04:55:04 +0200
commitb9455467863f194accf30a89b2c2998822f2c105 (patch)
tree5fb27bf4b8b8b00c7ed7ce414858733a595d3847 /src/main/kotlin/moe/nea/notenoughupdates/util
parente45378fd6b61a5871c306ca8439c8ee3d7dec456 (diff)
downloadFirmament-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.kt9
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)
+ }
+}