Loading...
beginner
Problem 02 • Step 01
Define and Use a Name
Now you’ll add two new rules to the evaluator: one for defining a name, and one for using it later.
What’s Happening Behind the Scenes
We’ve provided two built-in functions:
set(name, value)— stores a value so that it can be looked up later by its nameget(name)— looks up the value previously stored under a name
These functions manage a hidden “environment” — a place where all defined names and values are remembered.
Examples
evaluate(["pi", "=", 3.14]); // tells the evaluator: "pi means 3.14"
evaluate("pi"); // fetches the value associated with "pi" -> 3.14
Your Task
Fill in the two rules:
"define"should usesetto save a value under a name"read"should usegetto fetch a value by name
Write your code where it says // your code here.