List Commands Library for 50g
|
06-24-2017, 12:54 AM
(This post was last modified: 09-17-2018 03:35 PM by DavidM.)
Post: #1
|
|||
|
|||
List Commands Library for 50g
(The most recent version of the ListExt library is available at hpcalc.org)
Pier4r recently started a thread containing a variety of challenges designed to encourage the use of lists for solving problems in calculator programs. Working on those challenges gave me some ideas for a set of new RPL commands that would augment the built-in list processing features of the 50g, and I soon found that I had enough to start building a library for more generalized use. In an effort to avoid hijacking Pier's thread, I thought it might be best to have a separate one to discuss the implementation of some of the commands (it's a "work in progress", and not quite ready for the General Software Library). Note that while there is a small amount of overlap with the GoferList library, this one is intended to complement it as opposed to replacing it. It is my hope that anyone interested in list processing on the 50g will be able to make use of this, and will offer suggestions for improvements and new ideas for commands that would be useful. For more background on some of the commands, including some comparisons with GoferList and performance benchmarks, see the following posts: First post Performance and GoferList comparisons A thread pertaining to the implementation of LSHF, the "shuffling" command Edit 2017-09-10: From this point forward I'll edit this first post with the latest version to make it easier to find. Edit 2018-09-17: 1.2.1 release. ListExt Release Notes Version 1.2.1 2018-08-17 - LDDUP bug fixed: sublists weren't handled properly as of the last update. - LDDUP adjusted to better balance performance in cases where lists have mostly duplicates. - LPICK replaced with a faster version, especially for smaller lists. ______________________________________________________________________________ COMMAND SUMMARY List Creation (CREAT menu) LSEQ - creates a list of <count> integers as a sequence from 1..<count> LSEQR - creates a list of integers for the range specified LASEQ - creates a numeric sequence by repetitive addition of a constant LMSEQ - creates a numeric sequence by repetitive multiplication by a constant LDSEQ - creates a numeric sequence by repetitive division by a constant LMRPT - repeats list contents as indicated by count List Editing (EDIT menu) LDDUP - removes duplicates from a list LPOP - retrieves the first element in a list while leaving the rest on the stack LPOPR - retrieves the last element in a list while leaving the rest on the stack LPUSH - adds object to front of list LPSHR - adds object to end of list LPICK - returns a list containing identified elements in specified order LREPL - replaces list elements with a substitute object as indicated LINSR - inserts 1 or more elements into a list as indicated LRMOV - removes 1 or more elements from a list as indicated LFRST - returns the first <n> elements of a list LLAST - returns the last <n> elements of a list LRCL - recalls objects identified by variables in a list Element Arrangement (ARRNG menu) LROLL - rolls the list (equivalent to 1 LROT) LRLLD - "roll down" the list (equivalent to -1 LROT) LROT - rotates list elements left or right as indicated by count LSWAP - swaps the positions of two list elements LSSR - reverses the order of a sub-sequence within a list LSHUF - shuffles the contents of a list KSORT - Sorts a list based on keys from a separate list REV - Reverses the individual elements of a list, string, or number Element Grouping (GROUP menu) LCLLT - collates a list of sublists LDIST - distributes list items into sublists (reciprocal of LCLLT) LGRP - replaces repeated elements with a single instance LRPCT - list with LGRP elements and another list of the count of each element LRPC→ - restores a list that was grouped with LRPCT LSDIV - subdivides a list into <count> sublists SPLIT - splits a list, string, or number as indicated into two parts RSPLT - splits a list, string, or number as indicated from the right into two parts LXIL - explodes inner sublists into individual elements (non-recursive) LXILR - recursive version of LXIL SLST→ - LIST→ that avoids Garbage Collection issues for large lists List Testing (TEST menu) LCNT - counts objects in a list LEQ - checks list items to see if any do not match MPOS - returns a list of all positions of an object in a list, or a substring in a string MPOSL - returns a list of all positions of an object in a list or its sublists LNRML - substitutes ROM opcodes in a list for numeric natural numbers in the range -9..9 LSAME - Executes LNRML on two lists then SAME Combinatorics (COMB menu) DOCOMB - feeds indicated combinations of a list to a user-supplied program DOPERM - feeds indicated permutations of a list to a user-supplied program List Math (LMATH menu) LSUM - ΣLIST that also accepts lists with 0 or 1 element LPROD - ΠLIST that also accepts lists with 0 or 1 element LMAX - returns the maximum value contained in a list LMIN - returns the minimum value contained in a list String/Number Conversion (STRNG menu) CHR+ - adds an offset to the CHR value of each character of a string LCASE - converts upper case characters in a string to lower case UCASE - converts lower case characters in a string to upper case RPTCHR - creates a string of repeated characters I→NL - converts an integer to a list of numbers NL→I - converts a list of numbers to an integer S→NL - converts a string to a list of numbers NL→S - converts a list of character numbers to a string S→SL - converts a string to a list of characters SL→S - converts a list of characters to a string I→BL - converts an integer into a list of remainders after repeated division by constant BL→I - converts a list of remainders from base conversion into an exact integer Stack Operations (STACK menu) NMDUP - replicates a group of stack levels as indicated NMROT - rotates stack items as indicated SWPXY - swaps the indicated stack levels DRPXY - drops the stack levels indicated in the range from X to Y REVN - reverses the order of N stack levels REVXY - reverses the order of stack levels X through Y About1423 - Library short description and version information Unins1423 - Detaches and deletes the ListExt library Not included in the menu: MENU1423 - activates the ListExt menu |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)