The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
48: Moving average with DOSUBS
06-12-2015, 01:27 PM
Post: #1
48: Moving average with DOSUBS
I need to whip up a quick moving-average program. This doesn't work:

Code:
AVG:
\<< DUP \GSLIST SWAP SIZE / \>>

MAVG:
\<< \-> L N
  \<< L N \<< N \->LIST AVG \>> DOSUBS \>>
\>>

And it's fairly obvious why: DOSUBS doesn't like the local name 'N' being present in the program it's being passed.

What's the trick to modifying a program on the stack? I figure I should be able to recall the value of N, prepend it to \<< ->LIST AVG \>>, and have a program that DOSUBS will take. You can't simply concatenate programs with +, and while it works with lists, DOSUBS won't accept the function stored as a list.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
48: Moving average with DOSUBS - Dave Britten - 06-12-2015 01:27 PM



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