> ... it occurs to me we might be able to do this in the
> HP48 itself using RPL. We would have to create an application which
> interacts with the user "normally", but also stashes each entered
> command into an HP48 program variable. Has anyone done this?
FWIW, the ability you seek exists in ND1 (an iOS RPL calculator).
There're record and stop soft-keys in the Program menu.
This technique is, of course, limited to recording a sequence of
commands, when useful programs usually contain control structures
(IFs, FORs, DOs, etc.).
However, with list processing, IFT and IFTE, and an efficient way to
produce lists {1...n}, you can often replace IFs and FORs, and this
technique becomes really powerful for interactive program development,
where you see step-by-step what is happening to test data. A real
advantage of RPN in this: as you enter the test data before your first
command, you can opt to not record it, and thereby obtain a function
that will work with different input data, without editing.
An example to illustrate what I'm talking about:
Say you want to write a function that computes the sum of all perfect
squares up to a given number.
Steps:
- Enter 10 (stack: 10; this be the test
data)
- Press record
- Enter 1 (stack: 10, 1)
- Press SWAP (stack: 1, 10)
- Enter range (stack: [1 2 3 4 5 6 7 8 9 10])
- Enter [ √ FP 0 == ]
- Enter filter (stack: [1 4 9])
- Enter total (or ∑LIST) (stack: 14)
- Press stop
The stack will now contain your program: ≪ 1 SWAP [√ FP 0 ==] filter
total ≫
As you didn't record the test data (10), it will use as input
whatever's on the stack, when you run it. That is, it is the desired
function. (And you know it works, because you saw the intermediate
results and the final result, as you performed the steps.)
You store the function and run it on 10000. Result: 338350
The function replaces this more traditional RPL program, containing
FOR and IF structures (which cannot be recorded in principle):
≪ \-> n ≪
0
1 n FOR i
IF i √ FP 0 ==
THEN
i +
END
NEXT
≫
≫
More about array processing and recording is in the latter portion of
this:
http://naivedesign.com/ND1/User_Functions.html
As an aside, with ND1 you can edit on your computer and run on your
iOS device a second later:
http://naivedesign.com/ND1/Computer_Link.html
(This is actually quite a bit more convenient than an emulator (or so
I find).)