Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 893 Bytes

README.md

File metadata and controls

51 lines (34 loc) · 893 Bytes

VAR

VAR extends IF with variable expressions:

x

A 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 1

Variables can also appear anywhere an expression is expected:

if zero?(-(5, v)) then i else v

VAR lets programs refer to predefined names, but they cannot introduce new names themselves yet.

For a closer look, read VAR: Variables and Environments.

Try it

You'll need Nix with flakes enabled.

nix develop
elm repl

Then:

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)