The Iterator
Sequentially navigating the vertices of a hyper-dimensional ward without exposing its internal representation.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Iterator
ARCANUM SCHOOL: Divination // Traversal
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// LEAN PATTERN //
namespace MathematicalWards
structure WardMatrix (A : Type) where
elements : List A
class Iterable (Collection : Type → Type) where
toList {A : Type} : Collection A → List A
instance : Iterable WardMatrix where
toList m := m.elements
def foldMatrix {A : Type} [Iterable C] (col : C A) (f : Nat → A → Nat) (init : Nat) : Nat :=
Iterable.toList col |>.foldl f init
end MathematicalWards
In functional languages, iteration is often abstracted as a conversion to a list or through direct fold/map typeclasses.
Runic Tags:
#behavioral
#lean4
#iterator
#wards