Walkthrough of an RPL program for an RPN programmer
|
08-26-2018, 03:37 AM
Post: #21
|
|||
|
|||
RE: Walkthrough of an RPL program for an RPN programmer
(08-25-2018 01:35 PM)Maximilian Hohmann Wrote: Thanks for that great thread! You're welcome! RPN vs. RPL RPN: Reverse Polish Notation RPL: Reverse Polish Lisp Some prefer postfix notation to using RPN. In the end it's used in multiple languages and contexts. Forth and RPL use RPN as well. In this forum RPN is often used as the language of the classic HP calculators which I consider unfortunate. For the user of the HP-19BII it's irrelevant whether the code was written in Saturn assembler or System RPL or whatever. As far as I know RPL as a programming environment is not exposed to the user. However you can write sophisticated programs using the solver. I'm not familiar with that calculator. Thus I don't know the details related to the entry system. It appears to be similar to the classic models. Quote:The best example for that is the expression « → a 'a+a' » of which, even after having read the whole thread, I still don't have the faintest idea what it might do. It takes the top level element of the stack, assigns it to the local variable \(a\) and evaluates the algebraic expression \(a+a\). In other words: it doubles the top level element. All of these programs do the same thing: Code: « DUP + » Code: « → a « a DUP + » » Code: « → a « a a + » » There are many ways to skin a cat. You might strife to make your code fast or small or easy to understand. Thus you may use local variables or then you may end up with unintelligible DUP ROT SWAP that you complained about. As an example you may compare the program without and with using local variables to calculate the area and the centroid of a polygon. In this case using local variables made the code faster, smaller and more intelligible. Here's a Python program for the Zeller's congruence: Code: def dow(m, q, y): And that's what I came up with for the HP-41C: Code: LBL "DOW" Compare the core of the calculation: Code: RCL 01 ; q with the corresponding part of the RPL program: Code: q Can you recognise the similarities? Quote:Max (still not convinced that RPL will ever be my thing) It was never the purpose of my post to persuade anybody of this forum. My goal was to show similarities and then of course differences between these two systems. For someone familiar with the HP-41C a lot of HP-48G's concepts are new:
But then others like the use of RPN are just the same. I was never much into the HP-50G. Even with the HP-48G I don't use all of its functions. But still I feel that I can write useful programs. It's maybe similar to the “batteries included” philosophy of Python. You may never use all of the libraries but once you need to parse a JSON file it's nice that you can just use a function out of the box. Chapter 29 Programmierung des HP 48 of the German Benutzerhandbuch is only 24 pages. Most of the stuff has already been handled within this thread. Kind regards Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)