lib for developers : libList +- HP Forums (http://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: lib for developers : libList (/thread-7001.html) |
lib for developers : libList - primer - 10-08-2016 03:37 PM Hello, The hpprime provide already many usefull list functions, mostly for math, But I'm sharing with you my libList v1 that provide some basic list functions for programming. API list : L_GET, L_SET, L_INS, L_DEL, L_MAP, ARR2LST and LST2VECT L_INS(lst,pos,item) Insert an item to a list. Retruns the new list if pos is null, insert at the end if pos<0, count -pos from right to insert at ex : Code: L_INS({11,22,33},1, 99); // returns {99,11,22,33} L_SET(lst,pos,item) Set (change) an item from a list. Retruns the new list. note : it does not add item, list size does not increase if pos is null, change the last item if pos<0, count -pos from left to change ex : Code: L_SET({11,22,33},1, 99); // returns {99,22,33} L_DEL(lst,pos) Remove an item from a list. Returns the new list if pos is null, remove the last item if pos<0, remove by counting -pos from the left ex : Code: L_DEL({11,22,33},1); // returns {22,33} L_GET(lst,pos) Get an item from a list. Returns the item if pos is null, get last item if pos<0, count -pos from left if pos exceed list size, return last ex : Code: L_GET({11,22,33,44},2); // returns 22 L_MAP(lst,userfunction) Call a function on each list item. Returns the list of function returns ex : Code: EXPORT myfct(a) // a userfunction ARR2LST(array) Convert vector or matrix to list resulting list have embeded lists in case of matrix ex : Code: ARR2LST([1,2,3]); // returns {1,2,3} LST2VECT(lst) Convert a simple list to a vector note : list items must be numbers ex : Code: LST2VECT({1,2,3}); // returns [1,2,3] SPLIT(string,separator) Split a string into a list separator can be any size. ex : Code:
|