[prev] [index] [next]

Exercise: Reverse Polish Notation (cont)

Implement a reverse polish calculator.

Example:

1 2 +                  (1 + 2)
= 3
3 2 *                  (3 * 2)
= 6
4 3 + 6 *              ((4 + 3) * 6)
= 42
1 2 3 4 + * +          ((3 + 4) * 2) + 1)
= 15
1 2 + 5 * 7 - 4 /      ((((1 + 2) * 5) - 7) / 4)
= 2