Re: Average of a [stack]

Liste des GroupesRevenir à cl forth 
Sujet : Re: Average of a [stack]
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forth
Date : 12. Jul 2024, 09:06:19
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2024Jul12.100619@mips.complang.tuwien.ac.at>
References : 1 2 3
User-Agent : xrn 10.11
Buzz McCool <buzz_mccool@yahoo.com> writes:
On 6/7/2024 1:32 PM, LIT wrote:
: AVG  DEPTH 0 SWAP DUP >R 0 DO SWAP + LOOP R> / . ;
>
I coincidentally was doing averaging for the floating point stack when I
ran across this posting. Other than adding stack comments, how can I
improve this word?

Eliminate DEPTH, e.g., by replacing it with a count of the elements
you want to average over, or better, write a word that takes only a
descriptor of, e.g., an array in memory, and averages over the array.

Why should DEPTH not be used in this way?  Because it means that AVG_
consumes the whole stack and is useless in a word that keeps some
temporary data deeper in the stack when it calls another word, an
idiomatic way of using Forth.

- anton
--
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: https://forth-standard.org/
   EuroForth 2024: https://euro.theforth.net

Date Sujet#  Auteur
10 Jul 24 * Re: Average of a [stack]28Buzz McCool
11 Jul 24 +* Re: Average of a [stack]10dxf
11 Jul 24 i`* Re: Average of a [stack]9Buzz McCool
12 Jul 24 i `* Re: Average of a [stack]8dxf
12 Jul 24 i  `* Re: Average of a [stack]7Buzz McCool
15 Jul 24 i   `* Re: Average of a [stack]6Buzz McCool
18 Jul 24 i    `* Re: Average of a [stack]5minforth
18 Jul 24 i     `* Re: Average of a [stack]4Buzz McCool
18 Jul 24 i      +- Re: Average of a [stack]1minforth
19 Jul 24 i      `* Re: Average of a [stack]2dxf
19 Jul 24 i       `- Re: Average of a [stack]1Buzz McCool
11 Jul 24 +* Re: Average of a [stack]16dxf
11 Jul 24 i`* Re: Average of a [stack]15ahmed
11 Jul 24 i `* Re: Average of a [stack]14ahmed
11 Jul 24 i  `* Re: Average of a [stack]13minforth
11 Jul 24 i   `* Re: Average of a [stack]12ahmed
11 Jul 24 i    +- Re: Average of a [stack]1ahmed
11 Jul 24 i    `* Re: Average of a [stack]10minforth
11 Jul 24 i     `* Re: Average of a [stack]9ahmed
11 Jul 24 i      +- Re: Average of a [stack]1minforth
14 May 25 i      `* Re: Average of a [stack]7anthk
14 May 25 i       `* Re: Average of a [stack]6ahmed
14 May 25 i        +- Re: Average of a [stack]1ahmed
15 May 25 i        `* Re: Average of a [stack]4dxf
15 May 25 i         +* Re: Average of a [stack]2Hans Bezemer
15 May 25 i         i`- Re: Average of a [stack]1dxf
15 May 25 i         `- Re: Average of a [stack]1Hans Bezemer
12 Jul 24 `- Re: Average of a [stack]1Anton Ertl

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal