kotlin sequence builder
snippet in kotlin

kotlin sequence builder

user9440

val childNumbers = sequence {
 yield(1)
 print("AAA")
 yieldAll(listOf(2, 3))
}
childNumbers.forEach { print(it) } // 1AAA23
val nums = childNumbers.joinToString() // AAA
print(nums) // 1, 2, 3