Post Reply 
Little explorations with HP calculators (no Prime)
04-03-2017, 06:47 PM (This post was last modified: 04-03-2017 06:48 PM by pier4r.)
Post: #111
RE: Little explorations with the HP calculators
(04-02-2017 06:19 PM)DavidM Wrote:  Your application makes good use of lists,....

So while I will check your suggestion, the part that you used as example is repeated a tiny fraction of times in the entire procedure (although you made it pretty fast). I definitely need to try to use more STREAM and operations with lists and DOSUBS. The problem is as usual, first be correct, then be correct and fast.

Actually the most executed part, that I suppose is pretty inefficient, is to increase the value in a list. This is executed at least 480 times for main iteration. So for 1000 iterations it is 480k times.

for the moment I have this.
Code:

IncListElFunc
  \<<
    @ program to increase the value of element in a list
  
    @ input on the stack see variables
    
    @output, the list in input, modified, on the stack
    \->
    @external inputs
    lList 
      @list
    lPosV 
      @position of the element
    lincV 
      @increase
    @local var
    \<<
      lList lPosV
        @placing list and position on the stack
        @for storing, later.
      lList lPosV GET
      lincV +
        @getting the value and increasing it
      PUT
        @putting the increased value back
    \>>
  \>>

Now with an approach similar to yours and with operations between lists or STREAM or DOSUBS, I would need only to find a proper approach.

Actually I may do a sequence of 0 with NDUPN, then replace (with ROLLN or something similar) the value on the stack in the wanted position, then create the list and add the new list to the given one.

Does someone have a better way?

Wikis are great, Contribute :)
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 - pier4r - 04-03-2017 06:47 PM



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