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 |
|||
08-26-2018, 06:43 PM
Post: #22
|
|||
|
|||
RE: Walkthrough of an RPL program for an RPN programmer
(08-25-2018 01:35 PM)Maximilian Hohmann Wrote: Hello! 1. That's normal. things evolve. You can do things with awk 4.1 that are much different with awk 2.x . That is true for any language that evolved slowly over time. I'd say that it is life. A bit like German, you cannot say that the German today is the same of 150 years ago, but it is has the same name. 2. True and false. Everyone in every language has his style unless there is a mainstream guideline how to write code. In any case the important part is that "obscure" things can be explained. And there are few RPL experts here, the others (like me) are at most power users. 3. I do agree, unless the program is trivial. But which language is for an occasional user? I am interested here. Maybe basic? 4. There is the manual. 2500 functions (or let's say: 2500 non trivial words in a dictionary) are plenty, either one uses them night and day or one needs a lookup (and online discussion or community help too). And I strongly disagree with "less is more". No, to keep down development time having a function ready made, reliable and quite fast is gold. "Oh I want to SORT a list". Too bad, SORT doesn't exist. "Well I can use DOSUBS". Too bad, dosubs doesn't exists too. That's a lot of overhead only for sort. Without entering the realm of math functions. The RPL library, even without additions, is something amazing. It covers a lot of needs. I wish the 50g had more ram . But I need to push the prime too. Wikis are great, Contribute :) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)