How to parse a unary operator reverse Polish notation?

0 like 0 dislike
7 views
Did the surge arrester under this article: https://m.habr.com/post/282379/. All good, but the algorithm does not work correctly with carbon monoxide negation. How to fix?
by | 7 views

2 Answers

0 like 0 dislike
All good, but the algorithm does not work correctly with unary negation.

It is not designed to work with the unary negation.
How to fix?

The easiest way -- typing for unary negation a special character, different from the other operators.
Otherwise you'll have to enter an additional status-whether the previous character and whether he was the operator, and if so, to interpret immediately follows the operator '-' as unary.
by
0 like 0 dislike
Add your operator or function, and process.
(Out of the box ARF does not work with the unary negation)
by
110,608 questions
257,186 answers
0 comments
28,659 users