Post Reply 
Splitting Lists on Prime G2 - Help Needed
03-01-2023, 02:55 PM
Post: #1
Splitting Lists on Prime G2 - Help Needed
Hi everyone,

On my old HP48SX, I used to be able to split a list into individual elements on the stack by simply pressing EVAL. It was really useful, especially when working in RPN mode. However, I'm struggling to figure out how to do the same thing on my Prime G2. I've tried different methods, but nothing seems to work.

I believe this is a basic feature that should be available on the Prime G2, but I can't seem to find it. EVAL does not work. Can anyone provide any clues or tips on how to achieve this? Your help would be greatly appreciated.

Thanks in advance.
Find all posts by this user
Quote this message in a reply
03-02-2023, 08:23 PM
Post: #2
RE: Splitting Lists on Prime G2 - Help Needed
There is no function to put the contents of a list onto the stack because the Prime has no stack.

What you see on screen is a history of previous answers, not a stack in RPN or RPL terms.
Find all posts by this user
Quote this message in a reply
03-02-2023, 08:31 PM (This post was last modified: 03-02-2023 08:35 PM by Joe Horn.)
Post: #3
RE: Splitting Lists on Prime G2 - Help Needed
(03-02-2023 08:23 PM)BruceH Wrote:  There is no function to put the contents of a list onto the stack because the Prime has no stack.

What you see on screen is a history of previous answers, not a stack in RPN or RPL terms.

Even when it's in RPN mode? The Prime itself (and its manual) call it a "stack".


Attached File(s) Thumbnail(s)
   

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-02-2023, 10:08 PM
Post: #4
RE: Splitting Lists on Prime G2 - Help Needed
Well, in RPN-mode it definitely has a stack. It even has a swap command on the ","-key that swap the two lowest items on the stack. And you can build a pretty large stack if you wish, even though around 5 items often is enough.

Anyway, thank you for trying to help with my problem.

Anyone else? Can it be done with a simple program?
Find all posts by this user
Quote this message in a reply
03-02-2023, 11:37 PM
Post: #5
RE: Splitting Lists on Prime G2 - Help Needed
(03-02-2023 10:08 PM)PrimeG2_hp48sx Wrote:  Anyone else? Can it be done with a simple program?

Stack operations in RPN mode on the Prime are very limited and a program cannot manipulate the stack. However we can use some tricks to achieve "almost" what you need.

The following program assigns to the user key Shift Right_arrow a function which returns to the command line the different elements of the list in the stack level 1 (if there’s one), then pressing Enter will push these elements to the stack.

Code:
KEY KS_Right()
BEGIN
 IF TYPE(Ans(1))==6 AND Entry==2 THEN
  RETURN ΣLIST(EXECON("STRING(&1)+\" \"",Ans(1)));
 ELSE
  RETURN −1;
 END;
END;

Note: I’ve done limited testing so there may be some cases where it doesn’t work correctly.
Find all posts by this user
Quote this message in a reply
03-05-2023, 10:56 PM
Post: #6
RE: Splitting Lists on Prime G2 - Help Needed
Cool! Clever! Thanks.
Find all posts by this user
Quote this message in a reply
03-06-2023, 12:35 PM
Post: #7
RE: Splitting Lists on Prime G2 - Help Needed
(03-02-2023 10:08 PM)PrimeG2_hp48sx Wrote:  Well, in RPN-mode it definitely has a stack. It even has a swap command on the ","-key that swap the two lowest items on the stack. And you can build a pretty large stack if you wish, even though around 5 items often is enough.

Anyway, thank you for trying to help with my problem.

Anyone else? Can it be done with a simple program?

Apologies - your original message referred to the stack on the 48 and I hadn't realised you'd already found stack mode on the Prime. As you've seen, it's so limited I didn't want to get your hopes up. :-)
Find all posts by this user
Quote this message in a reply
03-10-2023, 10:24 AM (This post was last modified: 03-10-2023 09:06 PM by komes.)
Post: #8
RE: Splitting Lists on Prime G2 - Help Needed
Hi, Here is another option, a small program that puts on stack (in RPN mode) all elements from your list. But it does not work automatically. This is how to do it:

1. Run program with your list as an argument.
The elements will be displayed in Terminal.

2. Copy everything as it is with Shift-Copy.

3. Clear Terminal window with Backspace.

4. Go back to Home screen (in RPN mode!).

5. Paste what you have copied with Shift-Paste.

6. Press ENTER.

Quote:EXPORT RPSTK(LL)
BEGIN
LOCAL n;
FOR n FROM 1 TO SIZE(LL) DO
IF TYPE(LL)==2 THEN
PRINT(STRING(LL(n)+" "); //Must be space between quotation marks. Important!
ELSE
PRINT(LL(n)+" "); //Must be space between quotation marks. Important!
END;
END;
RETURN;
END;

It works for me, so maybe helps you too. Good luck.
A.Z.
Find all posts by this user
Quote this message in a reply
Post Reply 




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