HP Forums
All about lists - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: All about lists (/thread-11618.html)



All about lists - sasa - 10-20-2018 03:54 PM

The official manual seems do not provide any details about lists. It is quite obvious that CONCAT is not enough. As well, limit about size seems to be not specified, as well as resizing...

Let take, for example, following:
Code:

export SZ_List_T2()
begin
  print();

  local a := {};
  print(a);
 
  local i := 1; 
  repeat
   
    a[0] := i;
    print(a);    
    i := i + 1;

  until i == 5;

  print(" ");

  print ("After: print a[0]");
  print(a[0]);
  print(" ");

  print ("After: a[10] := 10");
  a[10] := 10;
  print(a);
  print(" ");

  print ("After: a[10000] := 10000");
  a[10000] := 10000;
  print("Size: " + size(a));
  print(" ");

  print("After: print a[0]");
  print(a[0]);

  print ("After: a[10001] := 2");
  a[10001] := 2;
  print("Size: " + size(a));
  print(" ");

  print("After: print a[0]");
  print(a[0]);

  print ("FINISHED!");
  editlist(a);
end;

As results show, it is now clear than enlarging list is possible simply by assigning data in desired index, while all gaps are filled with zero values. With zero index is possible to show last and adding new item. However, a command to delete an item from list as well seems to missing, requiring additional code to accomplish it.

If assign item with index over the limit, "Insufficient memory" error will be raised. However, in upper example (using terminal screen), program execution stops without any notice.

Furthermore, if execute EDITLIST wilth list contain 10000 items and then try to insert new row, latest public beta emulator silently terminates (at least on Linux). I would be interested what would happen on real calculator...

Some unofficial details are based on:
https://tiplanet.org/hpwiki/index.php?title=HP_Prime/Commands/Guides/All_About_Lists


RE: All about lists - pier4r - 10-20-2018 05:54 PM

little info. In my dormant project to make a over10k library (for large lists) in early check I made lists up to 100 MB (on the android app). Because a list item can be a list, that can have 10k elements as well. So making a workaround working with inner lists (having a prologue to tell the function where to find the values) can help to hold a lot of values.


RE: All about lists - sasa - 10-20-2018 06:49 PM

I wouldn't be surprised much if lists in Prime are organized as arrays with in small 64K blocks having pointers to data objects for faster access by index (instead use long walk from root node). For 32bit architecture, limit would be 16K pointers per block, which (by some reason) here is only 10K.

In any event, with 32/256MB of RAM, pure pointer based implementation of linked lists should have only that physical limit. If, however, are used such small blocks of memory for faster access, all that could be linked as well, avoiding additional work you have mentioned and making such limit unnecessary.

However, only Cyrille or Tim are able to elaborate more regarding internal organization of lists in Prime.


RE: All about lists - Joe Horn - 10-20-2018 09:01 PM

(10-20-2018 03:54 PM)sasa Wrote:  ... a command to delete an item from list as well seems to missing, requiring additional code to accomplish it.

Try the "SUPPRESS" command.

SUPPRESS({9,8,7,6,5,4,3},2) --> {9,7,6,5,4,3}
SUPPRESS({9,8,7,6,5,4,3},2,4) --> {9,5,4,3}

See the Help screens for "SUPPRESS" and "suppress" for more info.

Meta-Hint: I didn't know that this command existed either, but the built-in Help utility's built-in Search function is awesome.


RE: All about lists - sasa - 10-20-2018 11:01 PM

(10-20-2018 09:01 PM)Joe Horn Wrote:  See the Help screens for "SUPPRESS" and "suppress" for more info.

Meta-Hint: I didn't know that this command existed either, but the built-in Help utility's built-in Search function is awesome.

The problem is that I'm mainly relied so far on PDF User Guide from latest public beta (Third Edition: December 2017, Document Part Number: 813269-003), which on page 501 state:

"suppress

Given a list and an element, deletes the first occurrence of the element in the list (if there is one) and returns the result.
suppress(List, Element)

Example:
suppress([0 1 2 3 2],2) returns [0 1 3 2]
"

More clear name would be as well DELETE/REMOVE...

Apart from this fundamentally different explanation for SUPPRESS function, there is many important information missing in the "User Guide", especially recently added functionality, as for example WAIT(-1)...

Thank you for the hint, I can see now that context sensitive help from the emulator is much more detailed and probably more up to date. However that makes real problem to read and find related references.

Another problem of "User Guide" document is that there is no "Related/member functions" reference list, which would be quite useful, as some functions may be used on several different objects.

In any case, I will report all this directly to HP. They will probably fix the documentation accordingly.


RE: All about lists - Tim Wessman - 10-21-2018 10:56 AM

I don't like the name either. Unfortunately, the CAS author already made the function and to avoid introducing discrepancies we just followed along with it.


RE: All about lists - Giancarlo - 10-21-2018 01:06 PM

To find all the commands I need I now started using the html file that Tim extracted from the help menu of the Prime.

I just look for commands working with Lists or strings and so on with a simple search. If you do it you will discover for example the SUPPRESS command.

You can do it on the calculator itself. However I like to have a reference tool different from the calculator (a book, a tablet...).

Thanks

Giancarlo