10 lines
851 B
Markdown
10 lines
851 B
Markdown
|
For this task you are going to implement a very simple calculater using a stack.
|
||
|
To simplify this we are ignoring precedence and use post-fix operators (sometimes referred to as reverse polish notation). Post-fix operators are just like your normal infix ones. You just write them
|
||
|
at the end of the two operands. For example 3 + 4 becomes 3 4 +. This makes parsing way easier.
|
||
|
And because we are ignoring precedence, the term 3 4 5 + * is equal to 35.
|
||
|
|
||
|
The concept of a stack based calculator is pretty simple. Numbers simply get pushed on the stack and
|
||
|
operators pop the number of operands of the stack, calculate the result and push it back on.
|
||
|
At the end you can just pop of the result.
|
||
|
|
||
|
Because the parsing and the calculator would be a bit much for one task, we already implemented the parsing. Your task is to fill in the rest of the calculator.
|