/* * SPDX-FileCopyrightText: 2023 Linnea Gräf * * SPDX-License-Identifier: GPL-3.0-or-later */ package moe.nea.firmament.util fun T.iterate(iterator: (T) -> T?): Sequence = sequence { var x: T? = this@iterate while (x != null) { yield(x) x = iterator(x) } }