This appendix contains all functions available in the LISP System as of August 1962.
Each entry contains the name of the object, the property under which it is available (e.g., EXPR, FEXPR, SUBR, FSUBR, or APVAL), whether it is a pseudo-function, functional (function having functions as arguments), or predicate, and in some cases a definition of the function as an M-expression. In the case of APVAL's, the value is given.
The LISP Library is a file of BCD cards distributed with the LISP System. It is not intended to be used as input to the computer without being edited first. Have the Library file punched out, and then list the cards. Each Library function is preceded by a title card that must be removed. Some Library entries are in the form of a DEFINE, while some are in the form of an assembly in LAP. Note that some of them have auxiliary functions that must be included.
Elementary Functions
car[x] : SUBRcdr[x] : SUBR
The elementary functions car and cdr always have some sort of value rather than giving an error diagnostic. A chain of cdr's applied to an atomic symbol will allow one to search its property list. Indiscriminate use of these functions past the atomic level will result in non-list structure and may appear as lengthy or even infinite garbage expressions if printed.
CAR SXA CARX,4
PDX 0,4
CLA 0,4
PAX 0,4
PXD 0,4
CARX AXT **, 4
TRA 1,4
CDR SXA CDRX,4
PDX 0,4
CLA 0,4
PDX 0,4
PXD 0,4
CDRX AXT **,4
TRA 1,4cons[x,y] : SUBR
cons obtains a new word from the free storage list and places its two arguments in the address and decrement of this word, respectively. It does not check to see if the arguments are valid list structure. The value of cons is a pointer to the word that was just created. If the free storage list has been exhausted, cons calls the garbage collector to make a new free storage list and then performs the cons operation.
atom[x] : SUBR predicate
The first word on the property list of an atomic symbol contains
-1 or
in the address. The following
subroutine depends upon this, and on the fact that NIL is located
at 0 and *T* is located at -1 and has 1 as its complement pointer.
ATOM SXA ATOMX, 4
PDX 0,4
CLA 0,4 GET CAR OF ARGUMENT
PAX 0,4
TXL *+3,4,-2 TRANSFER IF NOT ATOMIC
CLA TRUE IF IT IS ATOMIC
TRA *+2
PXA 0,0 NIL IF NOT ATOMIC
ATOMX AXT **, 4
TRA 1,4
TRUE OCT 1000000eq[x;y] : SUBR predicate
eq is true if its two arguments are identical list structure.
EQ STQ X
SUB X
TZE *+3 TRANSFER IF EQUAL
PXA 0,0 OTHERWISE VALUE IS NIL
TRA 1,4
CLA TRUE VALUE IS *T*
TRA 1,4
TRUE OCT 1000000
X PZEequal[x;y] : SUBR predicate
equal is true if its arguments are the same S-expression,
although they do not have to be identical list structure in the
computer. It uses eq on the atomic level and is recursive.
Floating point numbers in S-expressions are compared for
numerical equality with a floating point tolerance of
. Fixed
point numbers are compared for numerical equality.
list[
] : FSUBR
The value of list is a list of its arguments.
null[x] : SUBR predicate
The value of null is true if its argument is NIL which is located at 0 in the computer.
NULL TZE *+3
PXA 0,0
TRA 1,4
CLA TRUE
TRA 1,4
TRUE OCT 1000000rplaca[x,y] : SUBR pseudo-functionrplacd[x,y] : SUBR pseudo-function
These list operators change list structure and can damage the system memory if not used properly. See page 41 for a description of usage.
Logical Connectives
and[
] : FSUBR predicate
The arguments of and are evaluated in sequence, from left to right, until one is found that is false, or until the end of the list is reached. The value of and is false or true respectively.
or[
] : FSUBR predicate
The arguments of or are evaluated in sequence from left to right, until one is found that is true, or until the end of the list is reached. The value of or is true or false respectively.
not[x] : SUBR predicate
The value of not is true if its argument is false, and false otherwise.
Interpreter and Prog Feature
These are described elsewhere in the manual:
APPLY, EVAL, EVLIS, QUOTE, LABEL, FUNCTION, PROG, GO, RETURN, SET, SETQ.
Defining Functions and Functions Useful for Property Lists
define[x] : EXPR pseudo-function
The argument of define, x, is a list of pairs
where each u is a name and each v is a X-expression for a function. For each pair, define puts an EXPR on the property list for u pointing to v. The function of define puts things on at the front of the property list. The value of define is the list of u's.
define[x] = deflist[x,EXPR]deflist[x,ind] : EXPR pseudo-function
The function deflist is a more general defining function. Its
first argument is a list of pairs as for define. Its second
argument is the indicator that is to be used. After deflist has
been executed with
among its first
argument, the property list of
will begin:
| .----.---. .---.---. .---.---. `->| -1 | |->|IND| |->| | |--> - - - `----'---' `---'---' `---'---' | V vi
If deflist or define is used twice on the same object with the same indicator, the old value will be replaced by the new one.
attrib[x;e] : SUBR pseudo-function
The function attrib concatenates its two arguments by changing the last element of its first argument to point to the second argument. Thus it is commonly used to tack something onto the end of a property list. The value of attrib is the second argurnent. For example
attrib[FF; (EXPR (LAMBDA (X) (COND ((ATOM X) X) (T (FF (CAR X))))))]
would put EXPR followed by the LAMBDA expression for FF onto the end of the property list for PF.
prop[x;y;u] : SUBR functional
The function prop searches the list x for an item that is eq to y. If such an element is found, the value of prop is the rest of the list beginning immediately after the element. Otherwise the value is u[ ], where u is a function of no arguments.
prop[x;y;u] = [null[x]
u[ ];eq[car[x];y]
cdr[x];
T
prop[cdr[x];y;u]]get[x;y] : SUBR
get is somewhat like prop; however its value is car of the rest of the list if the indicator is found, and NIL otherwise.
get[x;y] = [null[x]
NIL;eq[car[x];y]
cadr[x]; T
get[cdr[x];y]]cset[ob;val] : EXPR pseudo-function
This pseudo-function is used to create a constant by putting the indicator APVAL and a value on the property list of an atomic symbol. The first argument should be an atomic symbol; the second argument is the value is cons[val;NIL].
csetq[ob;val] : FEXPR pseudo-function
csetq is like cset except that it quotes its first argument instead of evaluating it.
remprop[x;ind] : SUBR pseudo-function
The pseudo-function remprop searches the list, x, looking for all occurrences of the indicator ind. When such an indicator is found, its name and the succeeding property are removed from the list. The two "ends" of the list are tied together as indicated by the dashed line below.
.- - - - - - - - - - - . | .---.---. | .---.---. .---.---. V .---.---. .---.---. `->| | |-->|IND| |->| | |-->| | |->| | |--> - - - `---'---' `---'---' `---'---' `---'---' `---'---' | `---> PROPERTY
The value of remprop is NIL.
When an indicator appears on a property list without a property following it, then it is called a flag. An example of a flag is the indicator TRACE which informs the interpreter that the function on whose property list it appears is to be traced. There are two pseudo-functions for creating and removing flags respectively.
flag[l;ind] : EXPR pseudo-function
The pseudo-function flag puts the flag ind on the property list of every atomic symbol in the list l. Note that l cannot be an atomic symbol, and must be a list of atomic symbols. The flag is always placed immediately following the first word of the property list, and the rest of the property list then follows. The value of flag is NIL. No property list ever receives a duplicated flag.
remflag[l;ind] : EXPR pseudo-function
remflag removes all occurrences of the indicator ind from the property list of each itomic symbol in the list l. It does this by patching around the indicator with a rplacd in a manner similar to the way remprop works.
Table Building and Table Reference Functions
pair[x;y] : SUBR
The function pair has as value the list of pairs of corresponding
elements of the lists x and y. The arguments x and y must be
lists of the same number of elements. They should not be atomic
symbols. The value is a dotted pair list, i.e.
pair[x;y] = [prog[u;v;m]
u:= x;
v:= y;
A [null[u]
[null[v]
return[m]; T
error[F2]]];
[null[v]
error[F3]];
m := cons[cons[car[u];car[v]];m];
u:= cdr[u];
v:= cdr[v];
go [A]]sassoc[x;y;u] : SUBR functional
The function sassoc searches y, which is a list of dotted pairs, for a pair whose first element that is x. If such a pair is found, the value of sassoc is this pair. Otherwise the function u of no arguments is taken as the value of sassoc.
sassoc[x;y;u] = [null[y]
u[]; eq[caar[y];x]
car[y];
T
sassoc[x;cdr[y];u]]subst[x;y;z] : SUBR
The function subst has as value the result of substituting x for all occurrences of the S-expression y in the S-expression z.
subst[x;y;z] = [equal[y;z]
x;
atom[z]
z;
T
cons[subst[x;y;car[z]];subst[x;y;cdr[z]]]]sublis[x;y] : SUBR
Here x is a list of pairs,
The value of sublis[x;y] is the result of substituting each v for the corresponding u in y.
Note that the following M-expression is different from that given in Section I, though the result is the same.
sublis[x;y] = [null[x]
y;
null[y]
y;
T
search[x;
[[j];equal[y;caar[j]]];
[[j];cdar[j]];
[[j];[atom[y]
y;
T
cons[sublis[x;car[y]];sublis[x;cdr[y]]]]]]]
List Handling Functions
append[x;y] : SUBR
The function append combines its two arguments into one new list. The value of append is the resultant list. For example,
append[(A B) (C)] = (A B C)
append[((A)) (C D)] = ((A) C D)
append[x;y] = [null[x]
y;T
cons[car[x];append[cdr[x];y]]]
Note that append copies the top level of the first list; append is like nconc except that nconc does not copy its first argument.
conc[
] : FEXPR pseudo-function
conc concatenates its arguments by stringing them all together on the top level. For example,
conc[(A (B . C) D); (F); (G H)] = (A (B . C) D F G H).
conc concatenates its arguments without copying them. Thus it changes existing list structure and is a pseudo-function. The value of conc is the resulting concatenated list.
nconc[x;y] : SUBR pseudo-function
The function nconc concatenates its arguments without copying the first one. The operation is identical to that of attrib except that the value is the entire result, (i.e. the modified first argument, x).
The program for nconc[x;y] has the program variable m and is as follows:
nconc [x;y] = prog[[m];
[null[x]
return[y]];
m:=x;
A [null[cdr[m]]
go[B]];
m:=cdr[m];
go[A];
B rplacd[m;y];
return[x]]copy[x] : SUBR
This function makes a copy of the list x. The value of copy is the location of the copied list.
copy[x] = [null[x]
NIL; atom[x]
x; T
cons[copy[car[x]];
copy[cdr[x]]]]reverse[l] : SUBR
This is a function to reverse the top level of a list. Thus
reverse[(A B (C . D))] = ((C . D) B A))
reverse[l] = prog[[v];
u:=l;
A [null[u]
return[v]];
v:=cons[car[u];v],
u:=cdr[u];
go [A]]member[x;l] : SUBR predicate
If the S-expression x is a member of the list l, then the value of member is *T*. Otherwise, the value is NIL.
member[x;l] = [null[l]
F; equal[x;car[l]]
T;
T
member[x;cdr[l]]]length[x] : SUBR
The value of length is the number of items in the list x. The list ( ) or NIL has length 0.
efface[x;l] : SUBR pseudo-function
The function efface deletes the first appearance of the item x from the list l.
efface[x;l] = [null[l]
NIL;
equal[x,car[l]]
cdr[l];
T
rplacd[l,efface[x,cdr[l]]]]
These four functionals apply a function, f, to x, then to cdr[x], then to cddr[x], etc.
Functionals or Functions with Functions as Arguments
maplist[x;f] : SUBR functional
The function maplist is a mapping of the list x onto a new list f[x].
maplist[x;f] = [null[x]
NIL; T
cons[f[x];maplist[cdr[x];f]]]mapcon[x;f] : SUBR pseudo-functional
The function mapcon is like the function maplist except that the resultant list is a concatenated one instead of having been created by cons-ing.
mapcon[x;f] = [null[x]
NIL;T
nconc[f[x];mapcon[cdr[x];f]]]map[x;f] : SUBR functional
The function map is like the function maplist except that the value of map is nil, and map does not do a cons of the evaluated functions. map is used only when the action of doing f[x] is important.
The program for map[x;f] has the program variable m and is the following:
map[x;f] = prog[[m];
m := x;
LOOP [null[m]
return[NIL]];
f[m];
m:= cdr[m];
go[LOOP]]search[x;p;f;u] : SUBR functional
The function search looks through a list x for an element that has the property p, and if such an element is found the function f of that element is the value of search. If there is no such element, the function u of one argument x is taken as the value of search (in this case x is, of course, NIL).
search[x;p;f;u] = [nulllx]
u[x]; p[x]
f[x];T
search[cdr[x];p;f;u]]
Arithmetic Functions
These are discussed at length in Section IV.
function | type | number of args | value | |
---|---|---|---|---|
plus | FSUBR | indef. |
![]() |
|
minus | SUBR | 1 | -x | |
difference | SUBR | 2 | x-y | |
times | FSUBR | indef. |
![]() |
|
divide | SUBR | 2 | list[x/y;remainder] | |
quotient | SUBR | 2 | x/y | |
remainder | SUBR | 2 | remainder of x and y | |
add1 | SUBR | 1 |
![]() |
|
sub1 | SUBR | 1 |
![]() |
|
max | FSUBR | indef. | largest of
![]() |
|
min | FSUBR | indef. | smallest of
![]() |
|
recip | SUBR | 1 | [fix[x]
![]() ![]() |
|
expt | SUBR | 2 |
![]() |
|
lessp | SUBR | predicate | 2 |
![]() |
greaterp | SUBR | predicate | 2 |
![]() |
zerop | SUBR | predicate | 1 |
![]() |
onep | SUBR | predicate | 1 |
![]() |
minusp | SUBR | predicate | 1 | x is negative |
numberp | SUBR | predicate | 1 | x is a number |
fixp | SUBR | predicate | 1 | x is a fixed point number |
floatp | SUBR | predicate | 1 | x is a floating point no. |
logor | FSUBR | indef. |
![]() |
|
logand | FSUBR | indef. |
![]() |
|
logxor | FSUBR | indef. |
![]() |
|
leftshift | SUBR | 2 |
![]() |
|
array | SUBR | 1 | declares arrays |
The Compiler and Assembler
compile[x] : SUBR pseudo-function
The list x contains the names of previously defined functions. They are compiled.
special[x] : SUBR pseudo-function
The list x contains the names of variables that are to be declared SPECIAL.
unspecial[x] : SUBR pseudo-function
The list x contains the names of variables that are no longer to be considered SPECIAL by the compiler.
common[x] : SUBR pseudo-function
The list x contains the names of variables that are to be declared COMMON.
uncommon[x] : SUBR pseudo-function
The list x contains the names of variables that are no longer to be considered COMMON by the compiler.
lap[list;table] : SUBR pseudo-function
The assembler LAP is discussed in appendix C.
opdefine[x] : EXPR pseudo-function
opdetine defines new symbols for the assembler LAP. The argument is a list of dotted pairs, each pair consisting of symbol and value.
readlap[ ] : EXPR pseudo-function
readlap reads assembly language input and causes it to be assembled using LAP The input follows the STOP card of the packet containing the readlap. Each function to be read in consists of a list of the two arguments of lap. These are read in successively until a card containing NIL is encountered. readlap uses remob to remove unwanted atomic symbols occurring in the listing. For this reason, it should only be used to read cards that have been produced by punchlap.
Input and Output
read[ ] : SUBR pseudo-function
The execution of read causes one list to be read from SYSPIT, or from the card reader. The list that is read is the value of read.
print[x] : SUBR pseudo-function
The execution of print causes the S-expression x to be printed on SYSPOT and/or the on-line printer. The value of print is its argument.
punch[x] : SUBR pseudo-function
The execution of punch causes S-expression x to be punched in BCD card images on SYSPPT. The value of punch is its argument.
prin1[x] : SUBR pseudo-function
prin1 prints an atomic symbol without terminating the print line. The argument of prin1 must be an atomic symbol.
terpri[ ] : SUBR pseudo-function
terpri terminates the print line.
The character reading, sorting and printing functions are discussed in appendix F.
startread pack opchar error1 numob
advance unpack dash mknam
endread digit
clearbuff liter
Functions for System Control, Debugging, and Error Processing
trace[x] : EXPR pseudo-function
The argument of trace is a list of functions. After trace has been executed, the arguments and values of these functions are printed each time the function is entered recursively. This is illustrated in the printed output of the Wang Algorithm example. The value of trace is NIL. Special forms cannot be traced.
untrace[x] : EXPR pseudo-function
This removes the tracing from all functions in the list x. The value of untrace is NIL.
The following pseudo-functions are described in the section on running the LISP system:
count, uncount, speak, error, errorset.
Miscellaneous Functions
prog2[x;y] : SUBR
The value of prog2 is its second argument. It is used mainly to perform two pseudo-functions.
prog2 [x;y] = ycp1[x] : SUBR
cp1 copies its argument which must be a list of a very special type.
| .---.---. .---.---. .---.---. `->| | |-->| | |--> - - - ->| |***| `---'---' `---'---' `---'---' | | | .----V------. .--V--------. .----V------. | FULL WORD | | FULL WORD | | FULL WORD | `-----------' `-----------' `-----------'
The copied list is the value of cp1.
gensym[ ] : SUBR
The function gensym has no arguments. Its value is a new, distinct, and freshly-created atomic symbol with a print name of the form G00001, G00002, ..., G99999.
This function is useful for creating atomic symbols when one is needed; each one is guaranteed unique. gensym names are not permanent and will not be recognized if read back in.
select[q;
;e] : FEXPR
The
's in select are evaluated in sequence from left to right
until one is found that
,
and the value of select is the value of the corresponding
. If no such
is found the value of
select is that of e.
tempus-fugit[ ] : SUBR pseudo-function
Executing this will cause a time statement to appear in the output. The value is NIL. (tempus-fugit is for MIT users only.)
load[ ] : SUBR pseudo-function
Program control is given to the LISP loader which expects octal correction cards, 704 row binary cards, and a transfer card.
plb[ ] : SUBR pseudo-function
This is equivalent to pushing "LOAD CARDS" on the console in the middle of a LISP program.
reclaim[ ] : SUBR pseudo-function
Executing this will cause a garbage collection to occur. The value is NIL.
pause[ ] : SUBR pseudo-function
Executing this will cause a program halt. Pushing START will cause the progr to continue, returning the value NIL.
excise[x] : SUBR pseudo-function
If x is NIL, then the compiler will be overwritten with free storage. If x is *T* then both the compiler and LAP will be overwritten by free storage. excise may be executed more than once. The effect of excise[*T*] is somewhat unreliable It is recommended that before executing this pair, remprop [*,SYM] be executed.
dump[low,high,mode,title] : SUBR pseudo-function
dump causes memory to be dumped in octal. The dump is from location low to location high. If the mode is 0, then the dump is straight. If the mode is 1, the words containing zero in the prefix and tag will be dumped as complement decrements am addresses. This is convenient for examining list structure.
intern[x] : SUBR pseudo-function
The argument of intern must be a PNAME type of structure, that is, a list of full words forming a prmt name. If this print name belongs to an already existing atomic symbol, this is found, otherwise a new one is created. The value of intern in either case is an atomic symbol having the specified print name.
remob[x] : SUBR
This removes the atom x from the object list. It causes the symbol and all its properties to be lost unless the symbol is referred to by active list structure. When an atomic symbol has been removed, subsequent reading of its name from input will create a different atomic symbol.
The LISP Library
The LISP Library is distributed as the second file on the LISP setup tape. To use any part of it, punch out the entire library and remove the part you wish to use. Be sure to strip off comment cards, unnecessary DEFINE cards, and unnecessary cards that close a define with )).
Some entries in the library have several parts or define more than one function.
traceset[x] : EXPR pseudo-function
traceset is a debugging aid. The argument x should be a list of functions names. Each of these functions must be an EXPR which has a PROG on the top level. traceset modifies the definition of the function so that every SETQ on the first level inside the PROG is traced.
For example, suppose a PROG has the statement (SETQ A X). At run time, if this statement is executed while x has the value (U V), then in addition to setting the variable a, the function will print out:
(A =)
(U V)
untraceset[x] is part of the traceset package. Its argument is a list of functions whose definitions are to be restored to their original condition.
punchlap[ ] : EXPR pseudo-function
punchlap allows one to compile functions and have the results punched out in assembly language LAP. The punched output is in a format suitable for readlap. The functions to be compiled into LAP are placed at the end of the packet following the STOP card. Each one is read individually and the result is punched out. No assembling into memory takes place. The process stops when a card containing the word NIL is encountered after the last function.
Each function must consist of a list of the form (name exp) which is the exact form for insertion into a define.
Part of punchlap is a dummy definition of lap. This prevents lap from being used withm the memory of this packet. The printout from punchlap is not a copy of the cards produced, only the internal functions have their LAP printed. The PNAMEs of atoms in the EXPRs and FEXPRs of punchlapped functions must not contain class C characters.
printprop[x] : EXPR pseudo-function
If x is an atomic symbol, all of its properties will be printed in the output. Nothing is changed by printprop.
punchdef[x] : EXPR pseudo-function
If x is a list of atomic symbols, each one having an EXPR or FEXPR will have its efimtion punched out. Nothing is changed.
APVAL's
The following is a list of all atoms with APVAL's on their property lists in the basic system and their values.
APVAL | value |
---|---|
BLANK | (BCD blank) |
CHARCOUNT | (character count during reading of characters) |
COMMA | , |
CURCHAR | (current character during reading of characters) |
DOLLAR | $ |
EOF | $EOF$ |
EOR | $EOR$ |
EQSIGN | = |
F | NIL |
LPAR | ( |
NIL | NIL |
OBLISTA.1 | (bucket sorted object list) |
PERIOD | . |
PLUSS | + |
RPAR | ) |
SLASH | / |
STAR | * |
T | *T* |
*T* | *T* |