HP Forums

Full Version: NewRPL: RPN with brackets (A * B) + (C / D) => (A B *) (C D /)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, one of the difficulties of reading a program code written in RPL and expressions, written Reverse Polish Notation (RPN) is knowing how to identify the scope of the expressions, that is, from where they begin and end.

One option is to add brackets () and to differentiate the ASCII symbols 28 and 29, use the hexadecimal values 276a 276b ❪❫

(A * B) + (C / D) => (A B *) (C D /) + => ❪A B *❫ ❪C D /❫

[Image: rpn_with_brackets.png]

Good idea?
Seems like a good chunk of extra typing for little return. I don't personally find RPN hard to read, at any rate on the scale of your examples.
(04-15-2018 03:48 PM)moonbeam Wrote: [ -> ]Isn't RPN/RPL's raison d'être the very absence of brackets?

I can sort of see brackets as syntactic sugar, but this purpose is better served by comments and pretty-printing.

is a NEW RPL reinvented, easier to use, codify, more powerful, more intuitive, auto-documented =]

pretty-printing in RPL is not possible because the expression has been separated (A B *) (C D /)
the idea of tabulation is a way of grouping and visualizing parts of expressions, the converter has an option [STACK] that performs something similar, please try it.

RPN online converter
http://www.hpmuseum.org/forum/thread-4032.html
I solely use expressions like 'A+B*(X-y)' when that sort of thing is needed (even then these days I prefer to compose the algebraic expression in RPL stack) and in program code I do use:

<<
A B C + - <CR>
TemperaryVAR SWAP DUP * / <CR>
>>

The only problem above is that the basic interpreter in the stock 50g will mix it up when you push it to the stack.

I think We should remember that in RPL opposite to RPN we do deal with OBJECTS which can be anything, but the objects are interacted with reverse polish logic.

So:
2(=1 object) A(=1 object) STO (=command)
3(=1 object) B(=1 object) STO (=command)
'A+B' (=1 object, composed from 3 (sub)objects or from 4 (sub)objects if you count the out most container as an object, which I think would be the most correct way)

"..." "STRING" + (object1 + object2)
>>>>
"...STRING"

<<'A' 'B' 'C' {} + + +>> (1 object composed from 7 (sub)objects (+1 obj.))
{'A' 'B' 'C'} (1 object)
Reference URL's