05-21-2014, 11:23 PM
Post: #19
 rprosperi Super Moderator Posts: 6,409 Joined: Dec 2013
RE: Programming Pad for RPL Programs
(05-21-2014 05:23 PM)Thomas Klemm Wrote:  In an article I used this SYSRPL code with stack-diagrams:
Code:
::                     ; z   C%>%%                ; x y   2DUP                 ; x y x y   DUP                  ; x y x y y   %%*SWAP              ; x y y^2 x   %%ABS                ; x y y^2 |x|   DUP                  ; x y y^2 |x| |x|   %%1+                 ; x y y^2 |x| |x|+1   DUPDUP               ; x y y^2 |x| |x|+1 |x|+1 |x|+1   %%*                  ; x y y^2 |x| |x|+1 (|x|+1)^2   4PICK                ; x y y^2 |x| |x|+1 (|x|+1)^2 y^2   %%+                  ; x y y^2 |x| |x|+1 (|x|+1)^2+y^2   %%SQRT               ; x y y^2 |x| |x|+1 √((|x|+1)^2+y^2)   %%+                  ; x y y^2 |x| √((|x|+1)^2+y^2)+(|x|+1)   3PICKSWAP            ; x y y^2 |x| y^2 √((|x|+1)^2+y^2)+(|x|+1)   %%/                  ; x y y^2 |x| Q   OVER                 ; x y y^2 |x| Q |x|   %%1                  ; x y y^2 |x| Q |x| 1 (…)
At least it helps me to understand the program.

Cheers
Thomas

Thanks Thomas, interesting style. And I'm sure you're damned happy to see such excellent comments when you come back to look at this code months (even hours!) later. I think I might have had the stack reversed (left-to-right vs. your right-to-left), so that the 'bottom' level is at the left side near the current commad, so you can always see the most immediate argument you are working with.

But I'm not critisizing, I'm just wondering out loud, and this is exactly why I asked - to get ideas from other folks tackling the same task.

--Bob Prosperi
 « Next Oldest | Next Newest »