Android ● ● ● Kotlin 2.3

Kodebits Day 16: Sequence Map Take

May 3 2026
Practice collections with a short kotlin challenge.

What does this print?

fun main() {
  val out = (1..6).asSequence()
    .map { it * 3 }
    .take(3)
    .toList()
  println(out)
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

[3, 6, 9]

Explanation:

Creates lazy sequence 1-6, multiplies each by 3, but take(3) truncates to first three only. toList() converts from lazy.

[/spoiler]


Further Reading