Post Reply 
(48G) GCD: Greatest Common Divisor
09-01-2018, 07:31 PM
Post: #17
RE: (48G) GCD: Greatest Common Divisor
(09-01-2018 07:12 PM)Thomas Klemm Wrote:  Is there another :: ; included somewhere?

Short answer:
Yes. Smile

Longer answer:
The savings in Werner's version comes because, in this case, there's only one command in between the REPEAT and END steps. In the RPL stream, the next item after the REPEAT has to be skippable, so if there's more than one command they all have to be encapsulated in a secondary so as to be a single entity. Here's the compiled versions of both programs:
Code:
::
  x<<
  xWHILE
  xDUP
  xREPEAT
  ::
    xSWAP
    xOVER
    xMOD
  ;
  xWHILEEND
  xDROP
  x>>
;

::
  x<<
  xWHILE
  xSWAP
  xOVER
  xDUP
  xREPEAT
  xMOD
  xWHILEEND
  xROT
  xDROP2
  x>>
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (48G) GCD: Greatest Common Divisor - DavidM - 09-01-2018 07:31 PM



User(s) browsing this thread: 1 Guest(s)