Post Reply 
Make list from stack
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 


Messages In This Thread
Make list from stack - tdh79 - 09-27-2024, 07:37 PM
RE: Make list from stack - tdh79 - 09-27-2024, 09:40 PM
RE: Make list from stack - Didier Lachieze - 09-27-2024, 10:21 PM
RE: Make list from stack - tdh79 - 09-29-2024 08:35 PM
RE: Make list from stack - CheshireChris - 09-28-2024, 06:32 AM



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