Post Reply 
Programming puzzles: processing lists!
02-14-2019, 05:01 PM
Post: #273
RE: Programming puzzles: processing lists!
On the subject of slow up list operations, there are a couple of ways of speeding up programs where items are appended to an existing list.

One is to store the list in a global (not local) variable. This prevents the system having to save a copy of the original list after every operation.

The best way is to not append items to an existing list in the first place. If there is a way to accumulate the items on the stack and then assemble them into a list using \->LIST that is the fastest way. For example, to create a list of 1000 RANDs:

Slow program:

Code:

\<< { }  1. 1000.
   START RAND +
   NEXT
\>>

Fast program:

Code:

\<< 1. 1000.
   START RAND
   NEXT 1000. \->LIST
\>>

Of course there are programs where the items must be in a list because intermediate list processing operations need to be performed. Unfortunately using arrays instead of lists will usually not be helpful in these cases.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - John Keith - 02-14-2019 05:01 PM



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