👽 APL GLYPHS DIFFICULTY: Adept Structural

The Composite

Form a hierarchy of interstellar fleets acting as a single monolithic swarm.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Composite
ARCANUM SCHOOL: Transmutation // Swarm-Weaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// APL PATTERN //
:Class FleetComponent
    ∇ R←PowerLevel
      :Access Public Shared
      R←0
    ∇
:EndClass

:Class Drone : FleetComponent
    ∇ R←PowerLevel
      :Access Public
      R←10 ⍝ Individual drone power ⍫
    ∇
:EndClass

:Class Squadron : FleetComponent
    :Field Private Units ← ⍬

    ∇ Add Unit
      :Access Public
      Units ← Units , Unit
    ∇

    ∇ R←PowerLevel
      :Access Public
      R ← +/ {⍵.PowerLevel} ¨ Units
    ∇
:EndClass

To command an alien swarm is to treat the whole exactly as one treats the individual. The Composite pattern binds solitary Drones (⍫) and massive Squadrons into a unified array. Calculating the total power level of the swarm employs the ancient each (¨) and reduce (+/) glyphs, cascading through the multidimensional hierarchy to sum the collective psychic energy of the armada.

Runic Tags: #apl #structural #alien #composite #swarm