Welcome to GoferLists 0.1 by Jarno Peschier (JPSOFT) This is a library for the HP48GX calculator that contains UserRPL versions of some of the functions that work on lists I took them from the standard.prelude of the functional programming language Gofer (except for the last four combinatoric ones, which come from my book on Functional Programming by Jeroen Fokker of the Utrecht University, INF/DOC-92-06). This is only a beta-test version, so there is no real documentation yet. However, I will give a list of which functions are in the library along with a minor description of what they do (and some small examples) for those not familiar with Gofer. The functions may take their arguments a little differenty To install, do the following: 1) download GL01.LIB to your HP48GX (binary mode) 2) recall GL01.LIB to the stack 3) purge GL01.LIB to save space (if you want) 4) enter the port number to put the library in (e.g. 0 for G models) 5) press STO 6) do a warmstart (turn the HP48 off and on again, or press ON-C) This should attach the library (number 1652) to the directory in which you were when you STO'ed the library. The functions in fact only use the G-series commands HEAD, TAIL and REVLIST (as far was I can remeber now). I could easily rewrite REVLIST to use the Gofer definition of reverse and something that gets the head and tail of a list with using only OBJ-> and ->LIST so a SX version should be possible. This version however is GX only! I've tested it (though not that thoroughly!) on my HP48GX rev. P. And now for the functions in the library. In the parameters column a {} will mean a list, n will mean an integer number, p will mean a program that takes one element from the stack and leaves a 0 or a 1 (boolean value) on the stack (a predicate), f will mean any program that would give no type-error's when used in the equivalent Gofer use. I know that last one is very vague, but Gofer is very strongly typed while these functions only check for the right number of arguments and if they are the right type. NAME PARAMETERS PURPOSE ========== =========== ============================================ Head {} Gives the first element of a list Last {} Gives the last element of a list Tail {} Gives the last n-1 elements of a list Init {} Gives the first n-1 elements of a list Length {} Gives the number of elements of a list Copy {} n Gives a list containing n copies of the input list put end to end Nub {} Removes duplicates from a list Reverse {} Reverses the order of the list elements Elem {} obj Gives a 0/1 answer if obj is in the list Concat {{}} Concatenates a list of lists to one list Null {} Gives 0/1 answer if the list is empty Map {} f Maps the program f on all elements of the list Filter {} p Only gives the elements that let predicate p give a 1 (True) answer Foldl f obj {} Gives "f(f(f(1,2),3),4)" of "f obj {1 2 3 4}" Foldr f obj {} Gives "f(1,f(2,f(3,4)))" of "f obj {1 2 3 4}" Take {} n Gives the first n elements of a list Drop {} n Gives the list without the first n elements TakeWhile {} p Take elements until p on an element gives 0 DropWhile {} p Drop elements until p on an element gives 0 Inits {} Gives all starting segments of a list Tails {} Gives all ending segments of a list Segs {} Gives all segments of a list Subs {} Gives all subsets of a list Some small examples: { 1 2 3 4 5 } Last = 5 { A B C } 3 Copy = { A B C A B C A B C } { 1 2 2 3 4 1 5 3 6 } Nub = { 1 2 3 4 5 6 } { { 1 2 3 } { } { 4 } { 5 6 } } Concat = { 1 2 3 4 5 6 } { 1 2 3 4 } << 1 + 7 R->C >> Map = { (2,7) (3,7) (4,7) (5,7) } { 1 2 3 4 5 6 7 8 9 } << 2 MOD 0 == >> Filter = { 2 4 6 8 } "<< + >> { } L Foldr" = the definition of "L Concat" { 1 4 3 6 7 8 7 6 5 } 5 Drop = { 8 7 6 5 } { 1 4 3 6 7 8 7 6 5 } << 7 < >> TakeWhile = { 1 4 3 6 } *ANY* reactions welcome to jpeschie@cs.ruu.nl Jarno Peschier JPSOFT, Utrecht