Re: Average of a [stack]

Liste des GroupesRevenir à cl forth 
Sujet : Re: Average of a [stack]
De : buzz_mccool (at) *nospam* yahoo.com (Buzz McCool)
Groupes : comp.lang.forth
Date : 15. Jul 2024, 18:18:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v73lm1$pnjq$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 7/12/2024 10:25 AM, Buzz McCool wrote:
On 7/10/2024 8:31 PM, dxf wrote:
Simpler to count down.  I find it easier writing for a common-stack model.
>
: FloatStackAvg ( rn ... r -- avg )
    fdepth dup >r ( count)
    begin  1- dup while ( not done)
      >r  f+ ( add two floats)  r>
    repeat  drop
    r> s>f f/ ( sum/count)
;
So for a separate floating point stack model:
: FloatStackAvg     ( rn ... r -- avg )
fdepth dup          ( count)
begin 1 - dup while ( not done)
f+                  ( add two floats)
repeat drop
s>f f/ ;            ( sum/count)

Date Sujet#  Auteur
11 Jul 24 * Re: Average of a [stack]9Buzz McCool
12 Jul 24 `* Re: Average of a [stack]8dxf
12 Jul 24  `* Re: Average of a [stack]7Buzz McCool
15 Jul 24   `* Re: Average of a [stack]6Buzz McCool
18 Jul 24    `* Re: Average of a [stack]5minforth
18 Jul 24     `* Re: Average of a [stack]4Buzz McCool
18 Jul 24      +- Re: Average of a [stack]1minforth
19 Jul 24      `* Re: Average of a [stack]2dxf
19 Jul 24       `- Re: Average of a [stack]1Buzz McCool

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal