Loading...
intermediate
Problem 06 • Step 01
double
This problem is different from everything before it. You won’t write any evaluator rules. The evaluator is complete and read-only — open evaluator.js to see it.
Instead, you’ll write a program in the language you’ve been building.
Your first program is double — a function that takes a number and returns it times two.
You already know how to define a function:
evaluate(["name", "=", ["lambda", "param", body]])
And you know how to express arithmetic:
["n", "*", 2]
Put those together. Define double so that calling evaluate(["double", 5]) returns 10.