Post Reply 
Little explorations with HP calculators (no Prime)
04-02-2017, 06:19 PM
Post: #105
RE: Little explorations with the HP calculators
Your application makes good use of lists, and as such it strikes me that there could be some good opportunities to use the built-in list processing features of RPL in certain spots. These features can sometimes simplify the coding of a program, though in my experience they don't usually help much in terms of performance.

In your program, one procedure I noticed seemed to be a good candidate for simplification using list functionality: the updWinList procedure.

I believe the following version of this procedure does the same thing as yours, but uses list processing methods instead of manual looping. In this particular case, it also performs slightly faster, but just barely.

List processing features are sometimes very difficult to conceptualize when reading code. I would recommend stepping through this in DBUG mode to get a better idea of what's happening.

Code:
  updWinList
  \<<
    @ program that updates the winner list given the
    @ last tournament result list (in stack level 1 on entry)

    @ determine maximum value of tournament result list
    DUP \<< MAX \>> STREAM

    @ create a new list with the maximum value in each position
    OVER SIZE NDUPN \->LIST

    @ use the above list to make a new one containing 1's
    @ in each position that matches, 0's in others
    \<< == \>> DOLIST

    @ ADD the winning positions to the finalTournResList
    finalTournResList ADD 'finalTournResList' STO
  \>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Little explorations with the HP calculators - DavidM - 04-02-2017 06:19 PM



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