🟢 CLOJURE GLYPHS DIFFICULTY: Apprentice Creational

The Builder Incantation

Constructing complex immutable constructs step by step using thread-first sigils.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Builder
ARCANUM SCHOOL: Transmutation // Constructmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CLOJURE PATTERN //
(ns tekromancy.builder)

;; In Clojure, the Builder pattern is often replaced by immutable maps
;; and the thread-first macro (->) to accumulate state naturally.

(defn create-golem []
  {:type :clay, :power 10, :runes []})

(defn bind-rune [golem rune]
  (update golem :runes conj rune))

(defn empower [golem power-boost]
  (update golem :power + power-boost))

(defn animate [golem]
  (assoc golem :status :animated))

;; Usage:
;; (-> (create-golem)
;;     (bind-rune :fire)
;;     (bind-rune :speed)
;;     (empower 50)
;;     (animate))

To construct a golem from raw ether, one does not mutate it. Instead, the Builder pattern flows through the thread-first sigil (->), sequentially weaving new aspects into an immutable entity until it is fully realized and animated.

Runic Tags: #creational #builder #clojure #immutable-glyphs