The Interpreter of Ancient Tongues
Parsing and evaluating arcane expressions encoded in functional trees.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Interpreter
ARCANUM SCHOOL: Divination // Linguistics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
interface ArcaneInterpreter
exposes [Expr, evaluate]
imports []
Expr : [
Power U64,
Amplify Expr Expr,
Dampen Expr Expr
]
evaluate : Expr -> U64
evaluate = \expr ->
when expr is
Power v -> v
Amplify e1 e2 -> (evaluate e1) + (evaluate e2)
Dampen e1 e2 ->
v1 = evaluate e1
v2 = evaluate e2
if v1 > v2 then v1 - v2 else 0
Runic Tags:
#fast-functional-wards
#roc
#interpreter
#ast