proomt

Search

Search posts, papers, and topics

All posts

Ray Wenderlich1 min readtutorialintro

Kodebits Day 95: Lazy Sequences [FREE]

Summary

This short Kotlin challenge demonstrates lazy sequences. It shows how `asSequence()` combined with `map`, `filter`, and `take` processes elements one at a time, evaluating lazily only when a terminal operation is called.

  • Kotlin `Sequence` processes elements lazily, one at a time, unlike `Iterable` which processes eagerly.
  • Intermediate operations like `map` and `filter` on a `Sequence` are not executed until a terminal operation (e.g., `toList()`) is called.
  • `take(n)` on a `Sequence` stops processing after `n` elements are collected, which can optimize performance for large datasets.
3/10

Related reading

  1. Kodebits Day 76: Elvis Operator [FREE]

    A short Kodebits tip introduces Kotlin’s Elvis operator for handling nullable values, showing how it supplies a default when the left side is null. It’s a quick reminder for Android developers working with null‑safety.

    Ray Wenderlichkodeco.com1 min
  2. Article: Your Next DSL Author Is a Language Model

    Typed Domain Grounding (TDG) embeds a DSL inside a mainstream language the LLM already knows (e.g., Kotlin) and uses the host compiler as an oracle. The author describes five building blocks—embedding, choosing a host language with high training‑data frequency, compiler‑driven type safety, a generate‑compile‑repair loop, and an on‑demand teaching tool—and shows measured results from kUML, a Kotli…

    InfoQinfoq.com18 min