Put it this way- what you have is eons ahead of what I have (Appears to be a challenge to texas intruments with more bells and whistles). Yes, my old (30-40 yrs?) Hp11C is pretty limited in comparison- but it still serves me well and as with yours- has entry of one number at a time. Having an unlimited stack does have pros and cons. Having the ability to enter multiple values with a single "enter" is a bonus -and you do have a handle on this. It appears that the core of what you do is defining and streamlining the stack entry and manipulations.-the actual arithmetic operations are straightforward but call on stack operations which may be defined as verbs in a basic way such as stack up and down that are called for again and again.

It also appears to be a fun project-tempting one to do more than the basic operations-are you so tempted?
LOL
Don


On 05/06/2014 4:11 PM, Kip Murray wrote:
I was emulating an HP 50g in rpn mode, which has an unlimited stack.
  However, entering more than one number at a time is not possible on the HP
50g !

On Thursday, June 5, 2014, Don Kelly <[email protected]> wrote:

it may depend on what you are trying to do.
Are you  trying (as it appears) to put in more than one stack element at a
time as in 1 2 enter puts 1 in "y" 1 in the "x "register?
I can see some advantage to this.
If you are trying to emulate something like an HP 11C (which I have in
front of me) then you have a different and probably simpler problem to do.
I have done it in Visual Basic-including trig and complex numbers-and I
know that J would do it better as it doesn't need a subroutine to handle
trig, logs etc with complex numbers..
the emulation involves single number entries where enter pushes the stack
up (x t0 y, y to z etc (duplicating x and discarding what was at the top of
the stack with the next entry replacing the x value.) with operations on
the x and y variables.
In other words enter has one function -this push up. and the +,- etc works
on the two bottom values, dropping the stack oppositely to enter
(duplicating the highers value and dropping z to y and the result of the
operation in x. -this is convenient in some cases).

Don Kelly

The following emulates a simple reverse Polish notation calculator which
operates on numbers at the bottom of a stack, replacing them by the
result.
   How would you do it?  (Beware of line wrap.)

     clear =: 3 : ',.STACK =: '''''
     enter =: 4 : ',.STACK =: STACK , x'  NB. x a list of numbers
     chs =: 3 : ',.STACK =: (_1 }. STACK), - _1 {. STACK'
     dup =: 4 : ',.STACK =: STACK , (- x) {. STACK'  NB. x a non-negative
integer
     plus =: 3 : ',.STACK =: ( _2 }. STACK), +/ _2 {. STACK'
     minus =: 3 : ',.STACK =: ( _2 }. STACK), -/ _2 {. STACK'
     times =: 3 : ',.STACK =: ( _2 }. STACK), */ _2 {. STACK'
     divide =: 3 : ',.STACK =: ( _2 }. STACK), %/ _2 {. STACK'

     clear''
     1 2 enter ''
1
2
     chs ''   NB. Change sign of bottom number
   1
_2
     2 dup''  NB. Can use dup to keep a copy of numbers about to be
combined
   1
_2
   1
_2
     plus''  NB. 1 plus _2 is _1
   1
_2
_1






----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to