[Edu-sig] More on RPN example
Gordon Worley
redbird@rbisland.cx
Sun, 30 Apr 2000 00:39:52 -0400
At 8:49 AM -0700 4/29/2000, Kirby Urner wrote:
>As for Tk, I think the obvious thing, which might be fun
>to do, would be to wrap a simple RPN calculator interface
>around your modules. I always prefered Hewlett-Packards
>RPN calculators to TI's parentheses-infested ones. You
>have an Enter key to push a value on the stack, which
>is 4 levels deep. Even had a roll key for rolling
>values around.
I'd very much like to do such an interface, but on the Mac that just
isn't really all that fesiable right now. Rumor has it, though, that
this could be changing in a week or two, so I may be posting back
here soon with a nice Tk example for everyone to use. If not, I
would really appreciate it if someone coded something up.
>E.g. 3 [enter] 4 + gets you 7 (in bottom stack
>position).
>
>After you hit [enter] the first time, 3 is in the "y"
>position on the stack (2nd level), with a copy in "x"
>i.e.:
>
>3 [enter] 4 +
>
>Stack
>a: a: a: a:
>z: z: z: z:
>y: y: 3 y: 3 y: ?
>x: 3 x: 3 x: 4 x: 7 <-------- visible
>
>What I'm forgetting (hence the question mark) is if
>the 3 stays in the y: position, so that repeated
>pressing of the + key gets you 10, 13, 16... (don't
>have a Hewlett-Packard around to test).
Just to clarify, the register you labeled as a is generally refered
to as t in all the HP documentation that I've seen. As for what
happens in the last step, x and y are operated on and the result put
into x, and the other registers copy down (i.e. y =z, z=t, t=t).
This is 4 Level RPN, and while nice, my program impliments something
closer to RPL, which has a variable size stack of infinite length (in
your examples, each of the 'empty' registers does contain a value,
even if it is just zero).
Anyway, submisions are welcome, especially if anyone wants to help me
impliment numpy support. I'll probably get to it eventually, but it
is not as immediately important as some other issues.
--
- Gordon Worley
http://www.rbisland.cx/
mailto:redbird@rbisland.cx