How do I learn RPL and solve this problem with it?
09-24-2017, 03:21 PM
Post: #6
 pier4r Senior Member Posts: 2,128 Joined: Nov 2014
RE: How do I learn RPL and solve this problem with it?
So I am really interested by your problem, that for what I understood is not that "difficult" for a couple of terms but for many it starts to be a challenge.

As usual, a lot of data is challenging to process in limited time.

So far I got "insufficient memory" (my 50g has 'only' 160 KB free in port 0) . I need to improve the algorithm because the search is too naive at the moment.

Nevertheless, such problems are always a chance to learn the vast amount of possible commands that the 50g offers. So thanks for it! (and I wonder how many others I miss that were posted here)

quick explanations nonetheless.

First of all my workflow. I use a windows XP system to develop for calculators and embedded devices.

What do I do? I have the 50g connected via USB. In notepad++ (using the "normal text language") I write my program. For this I create a duplicate of a template file and I call it with some name, like:

mathDirMisc.txt

The content at the start is this

Code:
 %%HP: T(0)A(D)F(.); @ alternative found online %%HP: T(3)A(R)F(.); @ You may edit the T(0)A(D)F(.) parts. @ The earlier parts of the line are used by Debug4x. @ in npp, just select language "normal" to get rid of the highlight.

(yes I picked the template from debug4x mostly)

Then I create a directory, because according to the topic I may have several programs. Even one program may be split in subprograms so a directory is a nice container for it.

Code:
 %%HP: T(0)A(D)F(.); @ alternative found online %%HP: T(3)A(R)F(.); @ You may edit the T(0)A(D)F(.) parts. @ The earlier parts of the line are used by Debug4x. @ in npp, just select language "normal" to get rid of the highlight. DIR   @here the code will be inserted END

Then I insert what I need, normally a program, so it gets like

Code:
 %%HP: T(0)A(D)F(.); @ in npp, just select language "normal" to get rid of the highlight. DIR   @here the code will be inserted   directoryEntryName   \<<      "hi there"      "notice that the name of this program is equal to 'directoryEntryName'"      "this program, when executed, will put those three strings on the stack"   \>> END

Note the use of digraphs, that are the ASCII translation of some important symbols on the 50g. In particular you find details about them in the hp 50g AUR. See http://www.hpmuseum.org/forum/thread-9090.html

With conn4x you can drag and drop the txt file on the calculator and it will be a valid directory afterwards.

Then it comes the actual program that I was trying.

Code:
 %%HP: T(0)A(D)F(.); @ in npp, just select language "normal" to get rid of the highlight. DIR   resistorsFindCouple   @2017-09-24-16-00   @Problem: given a list of resistors, compute any combination of two of them   @in series or parallel to find the one that is closer to the input value.   @see also www.hpmuseum.org/forum/thread-9150.html     @Todo:    @ - faster search of possible values.   @ - to precompute the list of resistors   @ - to extend to more than 2 resistors.      @requires:    @ - LSORT (see hp_calc_torrent and hpcalc.org)   @ - listExt from DavidM (see hpmuseum forum or hp_calc_torrent)   \<<     { 10 12 15 18 22 27 33 39 47 56 68 82 }  "baseResistors" DROP     DUP "allResistors" DROP     { 0.1 10 100 1000 10000 100000 1000000 } "resistorRanges" DROP          \->     @input          @localVar     baseResistors     allResistors     resistorRanges          \<<       @first we build the list of all possible resistors from the base one.              @for every element in the range of resistors we expand the list of available       @resistors       1 resistorRanges SIZE       FOR position         'allResistors'         baseResistors         resistorRanges position GET         *         STO+       NEXT              @now we order the resistors, although it is not strictly needed for the result       allResistors :2:LSORT EVAL 'allResistors' STO              @here we have all the resistors needed.       @now we need to compute all the possible compositions of those in serial or parallel.              allResistors       2       \<<         "" "stringTag" DROP                  \->         @input         inputList                  @var         stringTag         \<<           @we build the tag           inputList \->STR 'stringTag' STO                      @we compute the values                      @series           inputList LSUM           "S" stringTag +           \->TAG                      @parallel         \>>       \>>       DOCOMB     \>>   \>> END

but the search space is too large. So for now I have to think about something smarter. If you have questions about the simbols I used, ask! Asking is great to trigger possible explanations.

Wikis are great, Contribute :)
 « Next Oldest | Next Newest »

 Messages In This Thread How do I learn RPL and solve this problem with it? - setq - 09-24-2017, 12:48 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 01:29 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 01:44 PM RE: How do I learn RPL and solve this problem with it? - John Keith - 09-24-2017, 03:03 PM RE: How do I learn RPL and solve this problem with it? - setq - 09-24-2017, 03:18 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017 03:21 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 04:06 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 04:10 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 04:14 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 04:17 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 04:25 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 06:02 PM RE: How do I learn RPL and solve this problem with it? - Brad Barton - 09-24-2017, 06:35 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-25-2017, 05:48 AM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-25-2017, 04:08 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-25-2017, 05:39 PM RE: How do I learn RPL and solve this problem with it? - mfleming - 09-25-2017, 06:36 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-25-2017, 08:27 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 06:03 AM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 02:50 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 02:55 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 06:37 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 06:57 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 08:22 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-25-2017, 07:10 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-25-2017, 07:41 PM RE: How do I learn RPL and solve this problem with it? - David Hayden - 09-25-2017, 07:55 PM RE: How do I learn RPL and solve this problem with it? - emece67 - 09-25-2017, 08:04 PM RE: How do I learn RPL and solve this problem with it? - Gerson W. Barbosa - 09-26-2017, 04:37 PM RE: How do I learn RPL and solve this problem with it? - Dieter - 09-26-2017, 07:01 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 08:25 PM RE: How do I learn RPL and solve this problem with it? - Dieter - 09-26-2017, 08:36 PM RE: How do I learn RPL and solve this problem with it? - David Hayden - 09-25-2017, 08:17 PM RE: How do I learn RPL and solve this problem with it? - brickviking - 09-26-2017, 01:02 AM RE: How do I learn RPL and solve this problem with it? - John Keith - 09-26-2017, 12:06 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 02:29 PM RE: How do I learn RPL and solve this problem with it? - David Hayden - 09-26-2017, 01:02 PM RE: How do I learn RPL and solve this problem with it? - Dieter - 09-26-2017, 06:20 PM RE: How do I learn RPL and solve this problem with it? - Didier Lachieze - 09-26-2017, 06:46 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 10:20 PM

User(s) browsing this thread: 1 Guest(s)