HP Forums
HP Prime: MAKELIST in RPN mode? - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: HP Prime: MAKELIST in RPN mode? (/thread-252844.html)



HP Prime: MAKELIST in RPN mode? - toml_12953 - 10-13-2013

I'm trying to use MAKELIST in RPN mode but all I get are syntax errors. I've tried putting single quotes around the variable names, and around the entire function. Neither works

MAKELIST(A^2,A,1,10,1)
MAKELIST('A^2','A',1,10,1)
'MAKELIST(A^2,A,1,10,1)' This puts the MAKELIST function on the stack

Is there a way to do it?




Re: HP Prime: MAKELIST in RPN mode? - Tim Wessman - 10-13-2013

When you have functions that can accept multiple numbers of input, the only solution we were able to come up with was to specify the argument count. MAKELIST can accept either 4 or 5 arguments.

'A^2' 'A' 1 10 MAKELIST works, as does 'A^2' 'A' 1 10 MAKELIST(4) (those two are equivalent), or also 'A^2' 'A' 1 10 1 MAKELIST(5).

If a command does not automatically evaluate itself from the toolbox in RPN mode, this means that it has multiple argument counts that can be accepted and it needs further input on the number to take.

Something like MIN for example can take 1-16 arguments. That makes it very flexible, but means there is no way to use that in the "traditional" RPN style without disabling the flexibility.

TW

Edited: 13 Oct 2013, 6:52 p.m.


Re: HP Prime: MAKELIST in RPN mode? - BruceH - 10-13-2013

One way to do this would be to provide the argument count as a suffix to the function name and create the appropriate closure when compiled.

Thus MAKELIST2('A',45) compiles 'behind the scenes' to MAKELIST(2,'A',45). Set an arbitrary maximum of 9 or 99 so that when the function is decompiled you know when to stop and use the long form.[*}

I've long wished for something like this in RPL for commands like DROPN where you rarely wish to drop a variable number of items from the stack and DROP7, say, would be more space efficient and easier to comprehend than 7 DROPN - especially if the 7 has to be put on the stack first and a whole bunch of rotates done before things line up.

[*] Although for the Prime, the source is retained so decompilation not an issue