Post Reply 
HP 50g List function question
09-10-2017, 07:18 AM (This post was last modified: 09-10-2017 07:38 AM by pier4r.)
Post: #2
RE: HP 50g List function question
for the first problem, I am not sure if there is a built in solution or there is some neat solution somewhere in some library.

For the moment I can offer this:
(you need to type it either in the 50g or copy it in notepad and then copy it over through the connectivity kit)
Remember that symbols like "\<<" are the conversion of special characters in the hp font. See hp 50g Advanced user manual page J-2 (is in the appendix)
Code:

@www.hpmuseum.org/forum/thread-9028.html
    @ from { 1 2 3 4 } to { 1 3 6 10 }
    \<<
      0 "result" DROP
      
      \->
      @input
      inputList
    
      @local var
      result
    
      \<<
      
        @go through every element of the list
        @and increase the sum, leaving the current sum on the stack
        inputList
        1
        \<<
          'result' STO+
          result
        \>>
        DOSUBS
      \>>
    \>>


Also suggested:
- http://www.hpmuseum.org/forum/thread-8209.html
- http://www.hpmuseum.org/forum/thread-8555.html


For the second question you can use the ListExt from DavidM. (http://www.hpmuseum.org/forum/thread-8555.html , see last posts, the first post is not updated)

There is a command called LRMOV in the listExt library, but it removes the first 'n' objects, for the last 'n' you need to use a combination of commands (would be nice if LRMOV from the last would be added, hint hint).

Anyway there are commands to pick the first n or last n entries in the list.

So you have:
Code:

\<<
  @program to remove the first n entries

  \->
  inputList
  elementsToDelete
  
  \<<
    @we put the list on the stack for later
    inputList
  
    @it computes the size of the list
    inputList SIZE
    
    @on the stack there are
    @2: list
    @1: list size
    
    @we check now how many entries we should keep
    @ "size-n"
    elementsToDelete -
    
    @on the stack there are
    @2: list
    @1: size-n elements to keep
    LLAST
    
    @returns only size-n last elements
  \>>  
\>>


\<<
  @program to remove the last n entries

  \->
  inputList
  elementsToDelete
  
  \<<
    @we put the list on the stack for later
    inputList
  
    @it computes the size of the list
    inputList SIZE
    
    @on the stack there are
    @2: list
    @1: list size
    
    @we check now how many entries we should keep
    @ "size-n"
    elementsToDelete -
    
    @on the stack there are
    @2: list
    @1: size-n elements to keep
    LFRST
    
    @returns only size-n first elements
  \>>  
\>>

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP 50g List function question - Andres1 - 09-09-2017, 10:47 PM
RE: HP 50g List function question - pier4r - 09-10-2017 07:18 AM
RE: HP 50g List function question - pier4r - 09-10-2017, 09:40 AM
RE: HP 50g List function question - pier4r - 09-10-2017, 07:46 AM
RE: HP 50g List function question - DavidM - 09-10-2017, 03:28 PM
RE: HP 50g List function question - Juan14 - 09-10-2017, 07:41 PM



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