A calculator that understands
What it takes to build
Type into the box and watch the tree. That tree is the whole idea.
How it works — three stages:
1. Tokenise. Turn the characters 2, +, 3 into a list of meaningful pieces. Easy.
2. Parse. Turn that flat list into a tree, where the structure is the meaning. This is the clever part. 2 + 3 * 4 becomes a plus with 2 on one side and a times on the other — so the times happens first, because it's deeper in the tree.
3. Evaluate. Walk the tree from the bottom up. Three lines.
The bit that seems impossible until you see it: how does it know times binds tighter than plus? There's no rule for it anywhere. Instead you write one function per level of precedence, and each one calls the level below it. Precedence falls out of the shape of the code. Try 2 ^ 3 ^ 2 — you get 512, not 64, because powers group from the right, and that's one line of difference.
Press the broken one and watch it fail politely. Good error messages are most of what makes a language usable.
What to ask for:
Recursive descent parser for arithmetic: tokenizer, then one function per precedence level (expr calls term calls power calls primary), producing a tree, then a recursive evaluator. Right-associative exponent, unary minus, parentheses, and clear error messages naming what it expected.