(HP48) Beginner questions about RPL
|
10-23-2024, 05:16 PM
Post: #1
|
|||
|
|||
(HP48) Beginner questions about RPL
Hello
I have been using HP calculators (17b, 19b, 20s, 48sx, 48g) in the office for some time for general calculations. Especially the HP48 and I love the multi-line display and use the stack extensively. I am mainly just a software user and know little to nothing about programming. I would now like to write a few very small programs in RPL and have had a code created by Chatgpt regarding the Collatz function: Code: << Does anyone have time and can help me? I am not interested in optimal code, but in learning to understand the code as a beginner. Thank you very much 8years elementary school, 2y business school; no bachelor/master, etc.; but always interested in simple mathematics & calculators |
|||
10-23-2024, 05:28 PM
Post: #2
|
|||
|
|||
RE: (HP48) Beginner questions about RPL
This appears to be a variation of the following PRL program created by Joe Horn.
\<< 0 SWAP @ Put an empty loop counter in level 2. WHILE DUP 1 > @ Exit as soon as it gets to 1. REPEAT IF DUP 2 MOD @ is it odd? THEN 3 * 1 + @ yes? then multiply by 3 and add 1; ELSE 2 / @ no? then divide by 2. END SWAP 1 + SWAP @ Increment the loop counter. END DROP @ Lose the "1" and stop. \>> See the following Hailstone Path download at hpcalc.org. Joe has a very nice write-up that discusses this subject. https://www.hpcalc.org/details/6808 |
|||
10-23-2024, 05:43 PM
(This post was last modified: 10-23-2024 05:55 PM by Pälzer.)
Post: #3
|
|||
|
|||
RE: (HP48) Beginner questions about RPL
Thanks.
One more quick question: do the "\" in \<< and \>> have a meaning ? While searching here in the forum, I noticed that this is often used. Question 2: I would like to have the results in a list, as above { } ->L ... ... ->L I'm curious if this will work, I'll try it out tomorrow evening. edit: question 2 added 8years elementary school, 2y business school; no bachelor/master, etc.; but always interested in simple mathematics & calculators |
|||
10-23-2024, 06:04 PM
Post: #4
|
|||
|
|||
RE: (HP48) Beginner questions about RPL
(10-23-2024 05:43 PM)Pälzer Wrote: Thanks. Regarding question 1, "Those slashes mark characters that don't have equivalents in ASCII. A 48/49 series calculator will insert them into an RPL program transferred in "text" mode to a PC." See: https://www.hpmuseum.org/cgi-sys/cgiwrap...read=86798 |
|||
10-23-2024, 09:05 PM
(This post was last modified: 10-23-2024 09:30 PM by Gil.)
Post: #5
|
|||
|
|||
RE: (HP48) Beginner questions about RPL
To see the list of all intermediate numbers in the algorithm, the given code could be modified as follows:
\<< DUP "Start number" \->TAG 1 \->LIST 0 ROT WHILE DUP 1 > REPEAT IF DUP 2 MOD THEN 3 * 1 + ELSE 2 / END SWAP 1 + SWAP DUP 4 ROLL SWAP + UNROT END DROP "Steps" \->TAG \>> Or << DUP "Start number" ->TAG 1 ->LIST 0 ROT WHILE DUP 1 > REPEAT IF DUP 2 MOD THEN 3 * 1 + ELSE 2 / END SWAP 1 + SWAP DUP 4 ROLL SWAP + UNROT END DROP "Steps" ->TAG >> |
|||
10-24-2024, 08:04 AM
Post: #6
|
|||
|
|||
RE: (HP48) Beginner questions about RPL
Thanks Steve and Gil.
Code: END SWAP 1 + SWAP DUP 4 ROLL SWAP + UNROT I looked it up, UNROT was introduced with HP49, replaced the command with ROT ROT after looking through the manual. And the code works fine. I'll have to take a closer look at the code at the weekend (the lines 4-6 are no problem). Question 3: Are there any other members here who program with the HP 48, etc.? Do you use the buttons for the commands or alpha ... ? I have some trouble finding the respective keys. I think I'll have to make a list when I get the chance. 8years elementary school, 2y business school; no bachelor/master, etc.; but always interested in simple mathematics & calculators |
|||
10-24-2024, 08:36 AM
Post: #7
|
|||
|
|||
RE: (HP48) Beginner questions about RPL
(10-23-2024 05:43 PM)Pälzer Wrote: One more quick question: See: HP RPL TIO Table This also allows to copy and paste code to the iHP48. The string can then be translated using these IN and OUT programs. (10-24-2024 08:04 AM)Pälzer Wrote: Question 3: Are there any other members here who program with the HP 48, etc.? I do, but I'm not the only one here. (10-24-2024 08:04 AM)Pälzer Wrote: Do you use the buttons for the commands or alpha ... ? Mostly buttons but sometimes alpha is easier. |
|||
10-24-2024, 10:14 AM
(This post was last modified: 10-24-2024 10:16 AM by Gil.)
Post: #8
|
|||
|
|||
RE: (HP48) Beginner questions about RPL
For the special characters like Greek m (mu).
Type the ShiftGreenKey, then MinusSign (you get the character "). Type AlphaKey, then ShiftGreenKey, then 'Key (the key left to STOkey) and Press ENTER key (you get "Greek mu"). Now press AlphaKey twice (to block characters/letters in a row) and write the letters NUM (N is EVALkey, I is TANkey, M is the key left of STOkey) and Press ENTER key (you get the character NUMBER 181). Now with 181 in the Stack level 1 again press AlphaKey twice (to block characters/letters in a row) and write the letters CHR (C is AlphaKey and Ckey, H is AlphaKey and PRGkey and R is AlphaRightArrowKey) and Press ENTER key (and you get "mu" in quotation mark). The HP50G has a helpful alphabetical catalogue of the commands that you can pick up directly instead of taping the letters. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)