Michael de Kaste
08/08/2022, 10:16 AMfun holeFiller(spaces: Int, totalSum: Int): List<List<Int>> = buildList {
fun fill(sumToGo: Int, list: List<Int> = emptyList()) {
when (list.size) {
spaces - 1 -> add(list + sumToGo)
else -> for (i in 0..sumToGo) {
fill(sumToGo - i, list + i)
}
}
}
fill(totalSum)
}
However, if I want to have this with a sequence, the function "fill" needs to be specified as
suspend fun SequenceScope<List<Int>>.fill
It would be nice if an inner function of a sequence implicitly works like thisYoussef Shoaib [MOD]
08/08/2022, 1:27 PMsuspend
or explicitly isn't within a Sequence
Michael de Kaste
08/08/2022, 1:31 PM