You are on page 1of 2

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
1)
2)
3)
4)
5)
6)

install, do the following:
download GL01.LIB to your HP48GX (binary mode)
recall GL01.LIB to the stack
purge GL01.LIB to save space (if you want)
enter the port number to put the library in (e.g. 0 for G models)
press STO
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

4)))" of "f obj {1 2 3 {} n {} n Gives the first n elements of a list Gives the list without the first n {} p Take elements until p on an element gives {} p Drop elements until p on an element gives {} {} {} {} Gives Gives Gives Gives all all all all starting segments of a list ending segments of a list segments of a list subsets of a list Some small examples: { 1 { A { 1 { { { 1 { 1 "<< { 1 { 1 2 B 2 1 2 2 + 4 4 3 4 5 } Last = 5 C } 3 Copy = { A B C A B C A B C } 2 3 4 1 5 3 6 } Nub = { 1 2 3 4 5 6 } 2 3 } { } { 4 } { 5 6 } } Concat = { 1 2 3 4 5 6 } 3 4 } << 1 + 7 R->C >> Map = { (2.7) (5.3).f(3.Elem Concat Null Map list Filter predicate {} obj {{}} {} {} f Gives a 0/1 answer if obj is in the list Concatenates a list of lists to one list Gives 0/1 answer if the list is empty Maps the program f on all elements of the {} p Only gives the elements that let Foldl 4}" Foldr 4}" Take Drop elements TakeWhile 0 DropWhile 0 Inits Tails Segs Subs f obj {} p give a 1 (True) answer Gives "f(f(f(1.7) (3.2).4)" of "f obj {1 2 3 f obj {} Gives "f(1.7) (4.ruu.7) } 3 4 5 6 7 8 9 } << 2 MOD 0 == >> Filter = { 2 4 6 8 } >> { } L Foldr" = the definition of "L Concat" 3 6 7 8 7 6 5 } 5 Drop = { 8 7 6 5 } 3 6 7 8 7 6 5 } << 7 < >> TakeWhile = { 1 4 3 6 } *ANY* reactions welcome to jpeschie@cs.nl Jarno Peschier JPSOFT. Utrecht .f(2.