Post Reply 
How do I learn RPL and solve this problem with it?
09-24-2017, 01:44 PM (This post was last modified: 09-24-2017 01:47 PM by HP67.)
Post: #3
RE: How do I learn RPL and solve this problem with it?
It should go without saying there are at least two pieces to any programming task. The first one is you have to design your solution. That could mean selecting an algorithm or a formula etc. The second this is picking the language and system you want to write it for.

RPL is different from most languages in that it is stack-based. If you have a formula to solve a problem a lot of the effort that will go into coding it in RPL is to use the stack effectively. comp.lang.forth on usenet is a good source of info on how to think in stack-based terms. Unfortunately the noise level is pretty high there at times.

I am no expert in RPL either and I also have a long background in programming. I have written a bunch of RPL so as a fellow newbie I can tell you the way I got started.

I converted some programs from a language I knew and from algorithms that were stated clearly enough into RPL. I got out a big pad of paper and started making stack diagrams. I figured out which arguments would be input and then tried to figure out how to manage them on the stack. After a while I started focusing on how to maximize the use of the stack and keep temp variables on top or close to the top by reorganizing the calculations in a more stack-friendly way.

It is fun but it is also frustrating at times. Sometimes a mistake in your code will require you to make a lot more changes than you would in most other languages to fix it. On the other hand when you get a piece of RPL doing what you want I think you get a sense of satisfaction that lasts longer because in some ways RPL is harder.

There are several guys here on the forum who have written and debugged a lot of RPL. If you post code samples of things you tried that didn't work I'm sure they can help. If you can't get started, post a formula or two or describe the algorithm you want to implement and I'm sure you will get some ideas from the guys how to approach coding it in RPL.

I like RPL because I find it is extensible. I like building primitives and then making my solution out of those basic functions. Once they are tested and work correctly you can assemble a nice collection of tools that make every subsequent program that much easier. That method of approaching a solution is something I have always done. And I feel RPL is particularly good for people who like working that way.

"So I wrote a C program that generated a list of all series and parallel combinations of any two resistors sorted in value order. I then wrote another program that sorts them by closest match, reports the two values either side of the match and reports a percentage difference so I can evaluate tolerance."

You could break the RPL solution up into the same types of logical pieces. You could have a function that produces the list and then another function that sorts them, then another one or more that does the reports. The stack is great for holding lists and temporary values and you don't have to use variable names.

It ain't OVER 'till it's 2 PICK
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017 01:44 PM



User(s) browsing this thread: