VAR extends IF with variable expressions:
xA variable has a name, but its value comes from the environment in which it is evaluated.
VAR starts with this environment:
x ↦ VNumber 10
v ↦ VNumber 5
i ↦ VNumber 1Variables can also appear anywhere an expression is expected:
if zero?(-(5, v)) then i else vVAR lets programs refer to predefined names, but they cannot introduce new names themselves yet.
For a closer look, read VAR: Variables and Environments.
To try it, you'll need Nix with flakes enabled.
nix develop
elm replThen:
import VAR.Interpreter as I
I.run "x"
-- Ok (VNumber 10)
I.run "y"
-- Err (RuntimeError (IdentifierNotFound "y"))
I.run "if zero?(-(5, v)) then i else v"
-- Ok (VNumber 1)