|
|
|
|
reverse Polish notation
|
(Definition)
|
|
|
Whereas operators are traditionally placed between operands, with parentheses used to override operator precedence, it is possible to place operators to the right of operands, thus eliminating ambiguity and the need for parentheses, and even the need for rules of operator precedence. This is known as reverse Polish notation (after the Polish mathematician Jan Łukasiewicz who came up with Polish notation, abbreviated RPN), or postfix
notation. Invented by Australian philosopher Charles Hamblin, reverse Polish notation requires that the number of operands of a given operator be defined in advance.
For example,
probably means 47, but if the possibility exists that the author meant but neglected to put in parentheses, the expression could actually mean
. In reverse Polish notation, we could define the basic arithmetic operators to all be binary, and write
with the confidence that it will evaluate to 47 and not 45.
Reverse Polish notation is particularly advantageous for stack-based programming languages like Forth and Adobe PostScript. Most Hewlett-Packard calculators use reverse Polish notation (though a few, such as the HP-38G, use the sort of infix notation conventional to most calculators). Some beginning programming language courses give as an exercise to the student the implementation of an RPN calculator. Instead of having to remember multiple addresses for different variables and constants, most RPN implementations use a stack and a stack pointer to keep track of data.
The factorial notation (e.g., ) is a fairly common use of postfix notation in mostly infix contexts. (Most unary operators in C++ are prefix).
To convert from standard infix notation to reverse Polish notation, the Dutch computer programmer Edsger Dijkstra came up with the shunting yard algorithm.
|
"reverse Polish notation" is owned by Mravinci.
|
|
(view preamble)
See Also: Polish notation
| Other names: |
postfix notation, RPN, Zciweisakul notation, reverse-Polish, reverse-Polish notation |
|
|
Cross-references: shunting yard algorithm, prefix, unary, factorial, stack, constants, variables, multiple, infix notation, sort, calculators, languages, binary, arithmetic, mean, expression, number, even, right, place, operator precedence, operators
There are 10 references to this entry.
This is version 3 of reverse Polish notation, born on 2006-08-14, modified 2006-11-10.
Object id is 8251, canonical name is ReversePolishNotation.
Accessed 5770 times total.
Classification:
| AMS MSC: | 68N17 (Computer science :: Software :: Logic programming) | | | 03B70 (Mathematical logic and foundations :: General logic :: Logic in computer science) |
|
|
|
|
|
|
Pending Errata and Addenda
|
|
|
|
|
|
|
|
|
|
|