Communicating stack state transitions, a notation. « Next Oldest | Next Newest »

 ▼ Arne Halvorsen (Norway) Member Posts: 151 Threads: 18 Joined: Aug 2007 10-09-2007, 04:12 PM I will try using the following notation to communicate RPN program's effect on the stack and LASTX register: [d,c,b,a][e]->oper. desc.->[d',c',b',a'][e'] The first array with four elements represents the stack where d and d' refers to content of the T stack register and a and a' to content in the X stack register. The e and e' in the single element array refers to the LASTX register's content. Ofcourse actual letters or words used may be choosen to so fit the input/output for particular program. So for example to describe sqrt: [d,c,b,v][e]->sqrt->[d,c,b,sqrt(v)][v] and addition: [d,c,b,a][e]->+->[d,d,c,b+a][a] Ofcourse there are other (better?) ways using tables or some kind of bar diagram but think this may work and have the advantage of being easy and fast to type in text only documents. Anyone of your long time rpn hackers having an opinion on this topic? ▼ Valentin Albillo Posting Freak Posts: 1,755 Threads: 112 Joined: Jan 2005 10-09-2007, 05:17 PM Hi, Arne: Obviously it would be far easier on the eyes and more useful if you would use X, Y, Z, T and L instead of a, b, c, d and e, like this: ``` [X, Y, Z, T | L] -> Sqrt -> [Sqrt(X), Y, Z, T | X ] ``` or a variation thereof. Best regards from V. Edited: 9 Oct 2007, 6:17 p.m. after one or more responses were posted ▼ Arne Halvorsen (Norway) Member Posts: 151 Threads: 18 Joined: Aug 2007 10-09-2007, 06:16 PM Small details, but think your way of | replacement for my 'two array' notation looks better, will use. As for the actual letters, think may become confusing if variable bound to orginal position in register; there may be a chain of operation... And if x contains speed of light; use c. Now, for me LEFT maps to TOP (i.e. T) and I always think of LASTX as 'below' X register... Interesting that you turned it around! Perhaps most people find yours more natural, perhaps its because I am lefthanded :-). Hmmm, actual that is perhaps more readable... must think about it... to bad there aint enough people interested in this detail to have a poll! Thanks! Edited: 9 Oct 2007, 6:17 p.m. ▼ Walter B Posting Freak Posts: 4,587 Threads: 105 Joined: Jul 2005 10-10-2007, 02:44 AM God dag Arne, I like Valentin's notation better because the x-level -- which will change most frequently -- appears leftmost, i.e. first for people reading from left to right. Just my 20 milli-Euro ▼ JoseL Junior Member Posts: 19 Threads: 3 Joined: Jul 2007 10-10-2007, 03:18 AM Hi Arne, I agree with Valentin and Walter. It's the notation I have been using since my first steps in RPN. Best regards Arne Halvorsen (Norway) Member Posts: 151 Threads: 18 Joined: Aug 2007 10-10-2007, 03:19 AM I have arrived at the same conclusion myself... Good thing I asked :-) Chris McCormack Junior Member Posts: 23 Threads: 2 Joined: Aug 2007 10-10-2007, 01:26 PM I would advocate following the stack notation practices used with the programming language Forth. The lowest items on the stack appear to the right, only the applicable levels appear, and two dashes separate the 'before' and 'after' snapshots. For example: `( y x -- y+x )` would be a compact representation for the '+' key. If you want to explicitly show the entire stack (and Last X register) this could become `( t z y x | a -- t t z y+x | x ) ` Usually the stack comments would try to convey a little more meaning, such as: `( Lat1 Lon1 Lat2 Lon2 -- Bearing )` to document that calculates the initial great circle bearing to fly from point 1 to point 2. ▼ Arne Halvorsen (Norway) Member Posts: 151 Threads: 18 Joined: Aug 2007 10-10-2007, 01:43 PM Interesting, I remember in my young days there was a lot of talk about the FORTH language... The notation is good and very similar to Valentin's proposal I have addopted (good I did not go ahead with my orginal syntax). I do agree names should reflect nature of value. I use X, Y, Z, T, L for the 'bystanders'...

 Possibly Related Threads... Thread Author Replies Views Last Post HP Prime reset to factory state? BruceH 3 2,861 11-26-2013, 07:27 PM Last Post: BruceH HP 50g - select characters on the stack, copy/paste Sean Freeman 7 1,832 11-20-2013, 07:11 AM Last Post: Sean Freeman Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 1,499 11-19-2013, 08:59 AM Last Post: Miguel Toro [Download] libhpcalcs: a toolkit for communicating with Prime calcs... debrouxl 13 3,172 11-18-2013, 05:22 AM Last Post: debrouxl HP Prime: Converting number to Sci notation and back BruceTTT 1 943 11-12-2013, 02:11 AM Last Post: Phil Wipf emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 1,432 11-11-2013, 02:19 PM Last Post: Thomas Radtke HP Prime Stack operations from within a program John Colvin 1 957 11-08-2013, 09:45 PM Last Post: Helge Gabert Prime: Anyway to refresh stack? kris223 5 1,537 10-16-2013, 05:09 PM Last Post: kris223 hp prime - sending program results to the stack giancarlo 6 1,430 10-15-2013, 02:00 AM Last Post: Giancarlo HP Prime - RPN stack access from programs? Mike Mander (Canada) 10 2,380 09-30-2013, 11:20 AM Last Post: steindid

Forum Jump: