Android ● ● ● Kotlin 2.0

Kodebits Day 95: Lazy Sequences

Sep 19 2026
Practice sequences with a short kotlin challenge.

What is the output?

fun main() {
  val s = (1..6).asSequence()
    .map { it * 2 }
    .filter { it > 5 }
    .take(2)
  println(s.toList())
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

[6, 8]

Explanation:

Sequences evaluate lazily, processing elements one at a time.

[/spoiler]


Further Reading