Re: May the numbers speak

Liste des GroupesRevenir à cl forth 
Sujet : Re: May the numbers speak
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forth
Date : 12. Jun 2025, 03:32:05
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <fd6a264e8711464bf32a1d489fca1620139c4bbd@i2pn2.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 12/06/2025 4:48 am, Hans Bezemer wrote:
On 11-06-2025 20:00, dxf wrote:
On 11/06/2025 11:54 pm, LIT wrote:
Let's find out the difference between my
and "Mark Twain" 's approach to the solution
of "parsing 'time string' task". For simplicity
I'll do everything using DX Forth.
>
My solution is:
>
VARIABLE C6
VARIABLE C1
>
: TIMESTRSCAN ( addr count -- d )
  1 C6 !  1 C1 !
  >R >R 0 0 R> R>
  OVER + 1-
  DO
    I C@ DUP 58 =
    IF
      DROP
      C6 @ 60 * C6 !
      1 C1 !
    ELSE
      48 - C1 @ * C6 @ M* D+
      10 C1 !
    THEN
  -1 +LOOP
;
>
Same using stack ops:
>
: TIMESTRSCAN2 ( addr count -- d )
   >R >R  0 0  1 1 ( C6 C1)  R> R>
   OVER + 1- DO
     I C@ DUP 58 = IF  DROP
       DROP  60 * ( C6)  1 ( C1)
     ELSE
       48 -  *  OVER ( C6) >R  UM*  D+  R>  10 ( C1)
     THEN
   -1 +LOOP 2DROP ;
>
12% faster and 20% smaller by my measurement.
 
It's slightly faster than the original on 4tH:
real    0m5,527s
user    0m5,522s
sys    0m0,004s
 
Opcodes: his: 39, yours: 37

To my mind the variables were, if anything, a distraction.
A simple stack comment serving as a reminder achieved the
same thing.


Date Sujet#  Auteur
11 Jun 25 * May the numbers speak32LIT
11 Jun 25 +* Re: May the numbers speak25LIT
11 Jun 25 i`* Re: May the numbers speak - supplement24LIT
11 Jun 25 i `* Re: May the numbers speak - supplement23minforth
12 Jun 25 i  `* Re: May the numbers speak - supplement22dxf
12 Jun 25 i   `* Re: May the numbers speak - supplement21Paul Rubin
12 Jun 25 i    +- Re: May the numbers speak - supplement1LIT
12 Jun 25 i    +* Re: May the numbers speak - supplement8mhx
12 Jun 25 i    i`* Re: May the numbers speak - supplement7Paul Rubin
12 Jun 25 i    i +* Re: May the numbers speak - supplement5mhx
12 Jun 25 i    i i`* Re: May the numbers speak - supplement4Paul Rubin
13 Jun 25 i    i i `* Re: May the numbers speak - supplement3mhx
13 Jun 25 i    i i  `* Re: May the numbers speak - supplement2Paul Rubin
13 Jun 25 i    i i   `- Re: May the numbers speak - supplement1mhx
13 Jun 25 i    i `- Re: May the numbers speak - supplement1dxf
12 Jun 25 i    +- Re: May the numbers speak - supplement1ahmed
12 Jun 25 i    +- Re: May the numbers speak - supplement1minforth
12 Jun 25 i    +* Re: May the numbers speak - supplement2B. Pym
12 Jun 25 i    i`- Re: May the numbers speak - supplement1Paul Rubin
12 Jun 25 i    +- Re: May the numbers speak - supplement1peter
12 Jun 25 i    `* Re: May the numbers speak - supplement6B. Pym
13 Jun 25 i     `* Re: May the numbers speak - supplement5dxf
13 Jun 25 i      +* Re: May the numbers speak - supplement3Hans Bezemer
13 Jun 25 i      i`* Re: May the numbers speak - supplement2Paul Rubin
14 Jun 25 i      i `- Re: May the numbers speak - supplement1dxf
15 Jun 25 i      `- Re: May the numbers speak - supplement1dxf
11 Jun 25 `* Re: May the numbers speak6dxf
11 Jun 25  `* Re: May the numbers speak5Hans Bezemer
12 Jun 25   +- Re: May the numbers speak1dxf
12 Jun 25   `* Re: May the numbers speak3sean
12 Jun 25    +- Re: May the numbers speak1mhx
12 Jun 25    `- Re: May the numbers speak1minforth

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal