🐺 WOLFRAM ALCHEMY DIFFICULTY: Adept Structural

The Decorator Incantation

Dynamically augmenting spell behaviors by wrapping functions.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Transmutation // Enhancement
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MATHEMATICA PATTERN //
(* Base Spell *)
BaseHeal[] := {"Heal", 50};

(* Decorators (Higher-order functions) *)
Empower[spell_] := Function[
  With[{result = spell[]},
    {result[[1]] <> " (Empowered)", result[[2]] * 1.5}
  ]
];

Extend[spell_] := Function[
  With[{result = spell[]},
    {result[[1]] <> " (Extended)", result[[2]], "Duration: 10s"}
  ]
];

(* Usage *)
empoweredHeal = Empower[BaseHeal];
megaHeal = Extend[Empower[BaseHeal]];

Print["Base: ", BaseHeal[]];
Print["Empowered: ", empoweredHeal[]];
Print["Mega: ", megaHeal[]];
Runic Tags: #decorator #structural #higher-order #functions