The Iterator of the Leyline Path
Traversing the hidden nodes of a magical network without exposing its underlying table structure.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Iterator
ARCANUM SCHOOL: Divination // Pathfinding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// LUA PATTERN //
local function leylineIterator(nodes)
local index = 0
local count = #nodes
return function()
index = index + 1
if index <= count then
return nodes[index]
end
end
end
local hiddenNodes = { "Crystal Cavern", "Fairy Ring", "Ancient Oak" }
for node in leylineIterator(hiddenNodes) do
print("Traversing: " .. node)
end
Iterator
Lua’s native for...in syntax is an inherent manifestation of the Iterator pattern. By returning a closure—a glowing wisp that remembers its place along the path—the script safely traverses the universe’s tables without exposing the raw, underlying matrix.
Runic Tags:
#fae
#iterator
#traversal