HP 50g List function question
|
09-09-2017, 10:47 PM
Post: #1
|
|||
|
|||
HP 50g List function question
Hello everyone,
Does anyone know if there's a function that will turn a List into a list of accumulated numbers as in {a, b, c} to {a, a+b, a+b+c}. For example, {2, 7, 1, 9} to {2, 9, 10, 19} or {7, 1, 3, 6, 3} to {7, 8, 11, 17, 20} If not, is there a function that can eliminate the first or last 'n' terms on a List or separate a list in two (one of size 'n'). Thanks in advance, Sincerely, Andres |
|||
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:
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:
Wikis are great, Contribute :) |
|||
09-10-2017, 07:21 AM
(This post was last modified: 09-10-2017 08:32 AM by Gilles59.)
Post: #3
|
|||
|
|||
RE: HP 50g List function question
(09-09-2017 10:47 PM)Andres1 Wrote: {a, b, c} to {a, a+b, a+b+c}. Hi, with Gopher List Library : Code: « + » Scanl1 without external Library : Code: 1. |
|||
09-10-2017, 07:46 AM
Post: #4
|
|||
|
|||
RE: HP 50g List function question
goferlist
http://www.hpcalc.org/details/6529 how to install a library http://www.hpcalc.org/install.php (follow the info of the 49g) in short: save the library in your home. move it (with the filer for example), to the flash storage warm restart your 50g. (holding on and while holding pressing f3 , see hp50g user guide page G-3 (appendix) ) Then after the restart press right shift (the orange one) and then 2 (where LIB is written), there you can see your libraries on the soft menu. Wikis are great, Contribute :) |
|||
09-10-2017, 08:23 AM
Post: #5
|
|||
|
|||
RE: HP 50g List function question
(09-10-2017 07:18 AM)pier4r Wrote: 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) Hi Pier... Where is the last version of ListExt with LRMOV ? I dont find it. I suppose that REVLIST LRMOV REVLIST will do the job Quote: (would be nice if LRMOV from the last would be added, hint hint). Something like for example -3 LRMOV |
|||
09-10-2017, 08:48 AM
(This post was last modified: 09-10-2017 09:00 AM by Gilles59.)
Post: #6
|
|||
|
|||
RE: HP 50g List function question
(09-09-2017 10:47 PM)Andres1 Wrote: Hello everyone, With GoferList again (see Pier post to download the Library) : Code:
Without : Code:
|
|||
09-10-2017, 09:40 AM
Post: #7
|
|||
|
|||
RE: HP 50g List function question
(09-10-2017 08:23 AM)Gilles59 Wrote: Hi Pier... Where is the last version of ListExt with LRMOV ? I dont find it. Yup if the last update is not in the first post (or somewhere stable) it is difficult to find. Anyway the last update of the listExt so far is here: http://www.hpmuseum.org/forum/thread-855...l#pid78160 Wikis are great, Contribute :) |
|||
09-10-2017, 01:36 PM
Post: #8
|
|||
|
|||
RE: HP 50g List function question
(09-10-2017 07:21 AM)Gilles59 Wrote:(09-09-2017 10:47 PM)Andres1 Wrote: {a, b, c} to {a, a+b, a+b+c}. A nice, elegant version by Jeremy Hawdon, from Datafile Vol. 27 No.6: Code: \<< 0 SWAP 1. Really, though, anyone doing this sort of programming needs to have GoferLists and ListExt. John |
|||
09-10-2017, 03:28 PM
Post: #9
|
|||
|
|||
RE: HP 50g List function question
My attempt at this ended up being the same as Jeremy Hawdon's from John Keith's post. But the GoferList version is going to be hard to beat .
As for the secondary question (deleting n elements from end/splitting a list): I wouldn't use LRMOV for this, as it is designed with a different purpose in mind (deleting arbitrary, possibly non-contiguous elements as identified in a list argument). If you were to use the ListExt functions, there's several ways to approach it. Which one to use probably depends on the source of "n" and/or the intended use of the result. Probably the easiest is to use one of the newer commands (LFRST). If n is defined as the number of leading elements to keep: Code: { 1 2 3 4 5 6 } 4 LFRST => { 1 2 3 4 } Another of the newer commands (LRSPL) can be used if you know the complementary number (n becomes the number of trailing elements to delete). It splits the given list into two by setting the split point counting from the right: Code: { 1 2 3 4 5 6 } 2 LRSPL => { { 1 2 3 4 } { 5 6 } } ...then you would simply need to GET the first sublist. So combining the two operations together becomes: Code: { 1 2 3 4 5 6 } 2 LRSPL 1 GET => { 1 2 3 4 } If what you really wanted was simply "n" trailing elements, use the following: Code: { 1 2 3 4 5 6 } 2 LLAST => { 5 6 } |
|||
09-10-2017, 03:56 PM
Post: #10
|
|||
|
|||
RE: HP 50g List function question
Thanks so much everyone, I didn't expect such fast replies. I ended up using Jeremy Hawdon's version as it is very elegant and I only needed that for now, but I'll be sure to check out the GoferList and ListExt if I need more functions.
Thanks again, Andres |
|||
09-10-2017, 07:41 PM
Post: #11
|
|||
|
|||
RE: HP 50g List function question
For the first question:
« 1 « NSUB 1 > {OVER +} IFT » DOSUBS » |
|||
09-10-2017, 07:48 PM
Post: #12
|
|||
|
|||
RE: HP 50g List function question | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)