<lazySequence> We need something like this: privat...
# forum
r
lazySequence We need something like this: private val fibSeq = lazySequence(1) { i, f -> f(i - 1) + f(i - 2) } fun fib(i: Int) = fibSeq[i - 2] An example implementation: interface IndexableSequence: Sequence { operator fun get(index: Int): T } fun lazySequence(z: T, f: (Int, (Int) -> T) -> T): IndexableSequence = object : IndexableSequence { val map = mutableMapOf(0 to z) fun comp(iIn: Int): T { val i = max(0, iIn) return map[i] ?: f(i,...