Post Reply 
Make list from stack
09-27-2024, 07:37 PM
Post: #1
Make list from stack
I'd like to make a little program for calculating parallel resistance. Meaning I put several numerical values on the stack, make them into a list, invert the numbers, sum the list and invert again. Any idea if this is possible? It's dead simple in RPL but I don't know how to on the prime
Find all posts by this user
Quote this message in a reply
09-27-2024, 09:14 PM
Post: #2
RE: Make list from stack
You can manually and interactively create and manipulate lists
using the start view or the RPN view.

But AFAIK if you want to do it programmatically using PPL,
you have to use the predefined L0...L9 for list handling,
and vars for individual values, as there is no data stack access from PPL.

Once your list in L0...L9 contains your wanted values,
you can manipulate the list items en block using the supported functions.

I also miss the data stack of the HP 48 series,
but the Prime is based on a different data handling concept.
In addition, the target markets for the HP 48 and the Prome are totally different.

The Prime RPN stack app could be a nice base for data handling like you (and many others) prefer,
but unfortunately the is no known (to me) API from PPL to that RPN stack.

-- Ray
Find all posts by this user
Quote this message in a reply
09-27-2024, 09:40 PM
Post: #3
RE: Make list from stack
(09-27-2024 09:14 PM)Raymond Del Tondo Wrote:  You can manually and interactively create and manipulate lists
using the start view or the RPN view.

But AFAIK if you want to do it programmatically using PPL,
you have to use the predefined L0...L9 for list handling,
and vars for individual values, as there is no data stack access from PPL.

Once your list in L0...L9 contains your wanted values,
you can manipulate the list items en block using the supported functions.

I also miss the data stack of the HP 48 series,
but the Prime is based on a different data handling concept.
In addition, the target markets for the HP 48 and the Prome are totally different.

The Prime RPN stack app could be a nice base for data handling like you (and many others) prefer,
but unfortunately the is no known (to me) API from PPL to that RPN stack.
As i feared then Sad
Find all posts by this user
Quote this message in a reply
09-27-2024, 10:21 PM (This post was last modified: 09-27-2024 10:23 PM by Didier Lachieze.)
Post: #4
RE: Make list from stack
It is possible for a program to read the content of the stack but AFAIK not to write to or manipulate the stack.

The following program will do what you need, assuming you enter all the values on the stack, plus the number of values. For example : 50 Enter 50 Enter 2 Enter TEST Enter will return 25 in Home whether in RPN mode or not. But it will not "consume the values", so the values you enter will remain on the stack which is not how RPL works.

Code:
EXPORT TEST()
BEGIN
 LOCAL list:={},i:=Ans(1);
 WHILE i>0 DO
  list(0):=Ans(i+1);
  i:=i-1;
 END;
 RETURN (1/ΣLIST(1/list)); 
END;
Find all posts by this user
Quote this message in a reply
09-28-2024, 06:32 AM
Post: #5
RE: Make list from stack
You're fighting against the programming model of the Prime here. The natural way to do this on the Prime would be to enter the data as a list and iterate through it using the SIZE operator.

Chris
Find all posts by this user
Quote this message in a reply
09-29-2024, 08:35 PM
Post: #6
RE: Make list from stack
(09-27-2024 10:21 PM)Didier Lachieze Wrote:  It is possible for a program to read the content of the stack but AFAIK not to write to or manipulate the stack.

The following program will do what you need, assuming you enter all the values on the stack, plus the number of values. For example : 50 Enter 50 Enter 2 Enter TEST Enter will return 25 in Home whether in RPN mode or not. But it will not "consume the values", so the values you enter will remain on the stack which is not how RPL works.

Code:
EXPORT TEST()
BEGIN
 LOCAL list:={},i:=Ans(1);
 WHILE i>0 DO
  list(0):=Ans(i+1);
  i:=i-1;
 END;
 RETURN (1/ΣLIST(1/list)); 
END;

Thanks a lot! Smile
Find all posts by this user
Quote this message in a reply
Post Reply 




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