Problem. tokens is an arithmetic expression in Reverse Polish Notation (RPN): operands come first, then the
operator that combines them. Operators are + - * /; division truncates toward zero. Return the value.
["2", "1", "+", "3", "*"] → 9 ((2 + 1) * 3)
["4", "13", "5", "/", "+"] → 6 (4 + 13 / 5 = 4 + 2)
["6", "-4", "/"] → -1 (truncate toward zero, not down)
RPN needs no parentheses and no precedence rules: the order of tokens already says what to compute. That's why calculators, stack machines (the JVM, Python's own bytecode) and compilers use it internally.
ML context. Every framework turns your formula into something like this. PyTorch and JAX record operations in
the order they must run; a learning-rate schedule or a loss written in a config (base * min(1, step / warmup)) has
to be parsed into an evaluation order and then run thousands of times. Change C compiles such a formula once and
evaluates it at every step.