✨ ARCANUM RUNE DIFFICULTY: Adept Behavioral

The Iterator Leyline

Traverses a collection of enchanted items sequentially without exposing the underlying representation.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Iterator
ARCANUM SCHOOL: Divination // Scrying
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
effect emit<a>
  ctl yield(val: a) : ()

fun iterate-leyline(items: list<string>) : <emit<string>> ()
  items.foreach(yield)

pub fun main()
  val inventory = ["Health Potion", "Mana Potion", "Phoenix Down"]
  with handler
    ctl yield(v) { println("Scried: " ++ v); resume(()) }
  iterate-leyline(inventory)
Runic Tags: #koka #iterator #generator-effect