HP Forums

Full Version: HP Prime: MAKELIST in RPN mode?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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)' This puts the MAKELIST function on the stack

Is there a way to do it?

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.


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

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