MΓ³dulo 23 Β· Design Patterns (All 23 GoF) β LecciΓ³n 15 de 23 Β· ~6 min
Interpreter
Interpreter: evaluate sentences in a tiny language
Problem: you have a small grammar β rules, formulas, filters β and want to evaluate expressions written in it.
Be honest: full Interpreter is rare in app code. Most 'tiny languages' are better served by data + a fold, or a real parser gem. But the idea is worth knowing.
PawWalk scenario: a minimal price-adjustment rule: a list of ["add", n] / ["sub", n] tokens applied to a starting total.