Postfix quiz
Turn an expression into standard postfix one move at a time, with an operator stack.
Every move is checked; the finished answer is exactly what parse() writes.
How it works
- Operands (numbers, names) go straight to the output. A minus written directly on a number is part of it:
-5is one operand — unless a power or subscript follows (-2^2is −(2²), so that minus isneg). - Operators pop anything on the stack with higher or equal precedence, then get pushed.
^is right-associative, so it only pops strictly higher. - Unary minus is
neg: a prefix operator, pushed without popping anything. - Functions and opening brackets are pushed. A closing bracket pops until its match, then the match is discarded; the function stays until something of lower precedence comes along.
- Variadic functions (
max min sum prod gcd mean) bring their argument count when written:a b 2 max. A comma pops to the bracket, counts one argument, and is not written — just move on. - When the input runs out, pop everything left on the stack.
- Implicit products are read as
*(2x,2(x+1));<= >= != ==are written≤ ≥ ≠ =. Functions take brackets:sin(x).
Precedence, low to high, from the operator table:
Keys: O output · S stack · P pop · D discard · N next · Z undo · H hint · R do the next move for me. The expression is in the address, so a link shares it.
Infix
Postfix output
Stack (top first)
Done
Steps
| Token | Postfix after | Stack after (top first) |
|---|