tlhIngan-Hol Archive: Sat Sep 30 21:15:25 2000
[Date Prev][Date Next][Thread Prev][Thread Next]
PN & RPN
In a message dated 9/30/2000 04:00:47 Eastern Daylight Time,
[email protected] writes:
> Polish notation is when you put the
> operator before the operands, e.g. for 1 + 2, write + 1 2.
> So, for multiple additions, you'd write + + 1 2 3. This
> is naturally (1 + 2) + 3.
>
> But for reverse Polish notation, you write the operands
> first and the operator last. e.g. for 1 + 2, write 1 2 +.
> To add 1 and 2 and 3, you'd do 1 2 3 + +. However, this
> naturally enforces 1 + (2 + 3).
These are both right, but incomplete.
Polish Notation (or prefix notation) puts the function first, whereas
Reversed Polish Notation (RPN or postfix notation) puts the function last.
(The common order of 1 + 2 is also called infix notation.)
Thus infix 1 + 2 would be + 1 2 in PN, just as it's given above, and in RPN
it is 1 2 +.
But 1 + 2 + 3 has two different forms in PN and two different forms in RPN:
PN: + + 1 2 3 or + 1 + 2 3 and in
RPN: 1 2 3 + + or 1 2 + 3 +.
The differences are equivalent to the parentheses in infix notation.
lay'tel SIvten