λ SCHEME RUNE DIFFICULTY: Apprentice Creational

The Singleton

Ensuring absolute uniqueness across the arcane timeline through closed lexical environments.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Enchantment // Chronomancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCHEME PATTERN //
(define get-world-tree
  (let ((instance #f))
    (lambda ()
      (unless instance
        (set! instance 'Yggdrasil))
      instance)))

By capturing a binding in a lexical closure, a single immutable truth is preserved for all who invoke the function.

Runic Tags: #creational #scheme #closures #lexical-scope