HP Forums

Full Version: List Manipulation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to split a list into 2 or to say that A{}:= B{}(32-64)?

So that List A will now contain the 32,33,34.....64th entry in List B as it's first 32 spaces?

Short of that is there a way to tail(32)? To remove 32 entries from the beginning of a list?

Are there any good List manipulation guides or tutorials?
I think you may want the SUPPRESS command. Try the following in HOME:

MAKELIST(X,X,1,64)▶la;
SUPPRESS(la,1,32);
SUPPRESS(la,33,64);

-road
list({a,b}) will return a list from element a to b (or up to size(list)):
A:=B({1,32}) should do
FYI A, B are not list variables, so define a variable list first or use L1 etc.
My comments below are related to Home and PPL, not to CAS which may have other ways to manipulate lists.

(05-19-2023 09:25 PM)matalog Wrote: [ -> ]Is there a way to split a list into 2 or to say that A{}:= B{}(32-64)?

So that List A will now contain the 32,33,34.....64th entry in List B as it's first 32 spaces?

L1:=L2({32,64})

See page 552 of the manual:

"List references
Suppose L1:={5, "abcde", {1,2,3,4,5}, 11}. L1(1) returns 5 and L1(2) returns "abcde". L1(2, 4) returns 100 (the ASCII code for d) and L1(2,4,1) returns "d". L1({2,4}) returns {"abcde", {1,2,3,4,5},11}, extracting a sublist of all the elements from 2 through 4.
"

One additional thing for list references is about the zero index value:
L1(0) returns the last element of the list
L1(0):=n adds n as a new element at the end of the list

Quote:Short of that is there a way to tail(32)? To remove 32 entries from the beginning of a list?

SUPPRESS(L1,1,32)

Quote:Are there any good List manipulation guides or tutorials?

Nothing I would know, but I may have missed them.
You may find some of the list functions here useful.
(The routines in here try to handle edge cases which some of the built-in routines miss).
https://www.hpmuseum.org/forum/thread-94...light=List
It includes a summary of built-in list commands.
That's great, thanks guys.
I have a list A it is 64 bytes, and I want to remove 1 byte. Is there a quicker way to A:=A({1,63}); to remove the last element?
Reference URL's