Daniel G. Bobrow D. LuciLle Darley Daniel L. Murphy Warren Teitelman

Bolt Beranek and Newman Inc. 50 Moulton Street Cambridge, Massachusetts 02138

Contract No. ~~19(628)-5065 Project NO. 8668 Scientific Report No. 1

February, 1966

h he work reported was supported by the Advanced Research Projects Agency, P .R. No. CRL-56176, ARPA Order No. 627, dated 9 March 1965. )

Prepared for:

AIR FORCE CAMBRIDGE RESEARCH LABORATORIES OFFICE OF AEROSPACE RESEARCH UNITED STATES AIR FORCE BEDFORD, MASSACHUSETTS

THE BBN-LISP SYSTEM

Daniel G. Bobrow D. Lucille Darley Daniel L. Murphy Cynthia Solomon Warren Teitelman

Bolt Beranek and Newman Inc . 50 Moulton Street Cambridge, Massachusetts 021.38

Contract No. ~~19(628)-5065 project NO. 8668 Scientific Report No. 1

February, 1966

h he work reported was supported by the Advanced Research Projects Agency, P.R. No. CRI-56176, ARPA Order No. 627, dated 9 March 1965.)

Prepared for:

AIR FORCE CAMBRIDGE RESEARCH LABOIUTORIES OFFICE OF AEROSPACE RESEARCH UNITED STATES AIR FORCE BEDFORD, MASSACHUSETTS

is unlimited. TABU3 OF CONTENTS

Page

IX THE INTERNAL STRUCTUFB OF THE BBN-1;ISP SYSTEMm*e**m*.***e.*****w**.***e..,m*****e 11-1 III DESCRIPTION OF FUNCTIONS IN BBN-LIl5P 111-1

IV. LISTXNGS OF S-EXPRESSIONS OF EXPR "3 AND FEXPR'S**m.e*mm**em*m**.**m*.mtm.m*mm.IV-1 APPENDIX A - OPWATING THE BBN-LISP SYSTEP!

A-1 LISP LOADER ****.. .*.mew* *.*.I, *.em.. A.1-1 A-2 USING LISP FROM THE COMPUTER ROOM TELEWPE**~**~.eemm.*eme*momm*~*eA.2-1 A-3 USING LISP FROM A REMOTE DATIISET***A.3-1 APPENDIX B - INDEX TO ~CTIONSmemm..m.m.,.m..m..B.1-1 FOREWORD

The work reported here was performed at Bo:. Beranek and Newrnan Inc In Cambridge, Massachusetts for the Advanced Research Projects Agency under Contract No, AF lg(628) -5065. THE rnN-LISP SYSTEM

This report describes in detail the BBN-LISP system. Thfs LISP system has a number of unique features; most notably, it has a small core memory, and utilizes a dmfor storage of list stPucture. The paging techniques described here allow utilization of this large, but slov~, drum memory with a surprisingly small time penalty. These techniques are applicable to the design of efficient list processing systems embedded in time-sharing systems using paging for memory allocation, SECTION I.

LISP is a highly sophisticated list-procel3sing language which is being used extensively in the artificiiil intelligence re- search program at Bolt Beranek and Newman. This report describes our LISP system, which has a nunber of unique features. Ideally, a LISP system would hiive a very large, fast, random-access memory. However, magnetic core memory ( tbe only large scale random- access memory available) is very expensive relative to serial memory tlevices such as magnetic dms or discs. Since average access time to a word on a drum or disc is approximately 1000 times slower than access to a word in a core memory, ui3ir1.g a drum as a simple extension of core memory would redilce the operating speed of a system by a factor of 1000.

We have developed a special paging techniclue which allows utilization of a drum for storage with a much smaller time penalty. This technique allows us to makis effective use of a LISP system on our PDP-1 which has only 8392 18-bit words of 5 microsecond core memory and 92,312 words on a dm with an average access time of 16.5 milli13econds. In addi- tion, the techniques reported here would :improve the speed of operation of LISP systems embedded in i;ime-sharing systems using paging for memory allocatio~l. In these time- sharing systems the user is allocated only a small portion of core memory at any time, although his l~rogramcan address a large virtual memory. The portion of h:~sdata structure and/or program not in core is kept in a s:lower secondary storage medium such as a drum or disc. Tlius, to the user it is very similar to the situation on our P3P-1, except that a hardware mechanism makes the program t~an~sparentto the medium of storage of any page of his prog.ram.

Section I1 of this report describes the internal structure of the BBN-LISP system, and the mechanisms used to facili- tate fast use of dmstorage. Section I:CI describes the LISP functions which are built into the bi3sic system. Sec- tion IV contains listings of those functions which are defined in LISP.

Although we have tried to be as clear and complete as poss- ible, this document is not designed to be an introduction to LISP. Therefore some parts may be clear only to people who have had some experience with other LISP !systems. SECTION 11,

THE INTERNAL STRUCm OF THE BBN-LISP SYS'EN

The BBN-LISP System uses only a small core memory, but achieves a large memory capacity by utilizing a drwr.. This drum is used in three ways. First, the working prcgram is divided into three overlays, the read and print (input-cutput) program, the garbage collector, and the interpreter of 5-expressions. Only one of these overlays is in core at any tine, although a number of sub-programs common to all three remain in core at all times.

Secondly, the drum contains a large push-down 1.ist for use in running recursive programs. This push-down list is double- buffered; that is, the section of the push-down list used most recently is in core and the section used immediately preceding this section is also there, so that traveling between buffers does not necessitate a dmreference.

The third way of utilizing this large secondary store, the drum, is for storage of list structure. If the entire remaining drum storage was used simply as an extension of core memory, an access to the drum would be needed each time a new list element was referenced; and LISP would be reduced to operaating at drum rotation speed. Instead, the drum storage of list structure is divided into pages. Each page is currently 258 words (decimal); and each page contains its own free storage list. The -cons algorithm, for constructing a new list element, works as follows. To construct z = cons [x:y]:

1) If g is not an atom, and there is room on the page with -y, then place -z on this page 2) Otherwise, if x is not an atom, an3 there is room on the page with -x, put -z on that page 3) Otherwise, place -z on the page in -ore with maximum free storage.

This algorithm tends to minimize cross linbges between pages and to limft any single structure to a very few pages. Thus when working with this stmcture, it is unlikely that one will make references to more than a few pages for a relatively long period of time. Since these pages can reside in core, no drum references are needed. For example, in entwin@;the definition of a function, the entire definition tends to appear on a single page. Thus, during the interpretation of a function, multiple drum references are usually unnecessary.

Although we have not yet run this LISP system on a large problem where we can make a reasonable timing compa:rison, we can give the following anecdotal evidence for the increase in speed due to this paging system. The run light on the PDP-1 goes off when a drum swap is taking place. In an older version of PDP-1 LISP the drum was treated as an extension of core memory. When any problem was run, the run light seemed to go off completely, in- dicat- that the machine was spending almo:st a11 of its time doing dmtransfers. In this system, however, the run light seems to burn as brightly as the rest, indicating that relatively few drum transfer operations occur except when going between the three overlay packages, that is, when going from input and out- put back to the interpreter or going into a garbage collection. On the research computer, because of the d~vmstorage, we currently have in use an effective free storage list of approx- imately 25,000 LISP words, 1. e ., double wold pairs (pointers) . Each LISP word is, of course, two 18-bit PIrP-1 words. In the extended version of LISP that will be used on the hospital system we will have 256,000 LISP words for free storage.

There are a number of differences between %his system and 7094 LISP aside from the storage conventions. I'or example, the value of a variable is stored in a special value cell for that variable, that is, as -car of' the atom name. An atom is distinguished by its address, which is located in a fixed region of virtual memory space. Thus one need not reference a structure, but only look at its address, in order to tell whether or not it is an atom. If x is an atom, then cdr[x] is the property list of the atom, as in LISP. However, the print name of the atom is not to be found on this property list. The: user can only get at the prlnt name with the instructions pack- and unpack. Sim- ilarly, the definition of an atom as a function is hidden away from the user in a special cell associated with the atom name. Two functions, getd[x] and putd[x;def] are used ta get the def- inition of a function, and place the definjtion in the function cell of an atom, respectively. The value cf getdlx] on an atom defined as a machine language subroutine ie a numerical constant which bears some relationship to the instruction that must be executed to obtain access to the subroutine.

When a new function is entered, the old values of its variables are pushed down on the push-down list, and the current values are stored in the value cells. Since the current value of any variable is always to be found in its value1 cell, free variables are no problem. However, there is the usua.1 ariomalous case of conflfcting free variables ill functional ax8gurnents. This can be circumvented by using sufficiently un1qc.e variable names.

Because of the way variable values are stored, the main inter- preter, eval, obviously does not use an A-list, and is therefore a function of only one argument. The function evala deffned in the BBN-LISP System will simulate the ef'fect of the usual eval[x;a], -a being an A-list.

Different LISP systems employ different methods to achieve the following two effects in functions labelled FEXPR!sin 7094 LISP. These two effects are (1) giving a function the ability to have an indefinite number of arguments, and (2) giving a function the ability to receive its arguments unevaluate!d.

On the 7094 anFEXPR is defined by putting tihe function definition on the property list after the flag, FEXPR, and treating it as a special case in the interpreter. In BBN-LISP we call functions which have abilities (1) and (2) FEXPR1s,bt.t we define them differently. The way anFEKPR is defined irk BBN-LISP is as follows: instead of the usual lambda follc~wedby a list of variables, the defining form is preceded by nlamda followed by a list containing a single variable. When a function with an nlamda is entered, everything following the) function name in the form to be evaluated is placed on a sLngle list and becomes the value of the single argument of this FEXPR. This is passed to the function unevaluated. In order to evaluate any portion of this list, an explicit call to eval must be made. See "defineq" in the listings for an example of the use cbf this device. third reason FEXPR1s and FSUBR1s are used or1 7094 LISP is to make the A-list available to a program. Hourever, since there is no A-list in BBN-LISP this will notl concern us here.

Another major difference between BBN-LISP arid 7094 LISP is due to the fact that the 7094 has floating point hardware, and the PDP-1 does not. Any floating point machinery would have to be interpreted on the research computer. This would be expensive in both time and space, and, therefore, in this version of LISP there is only integer arithmetic. A compiler is being planned for the PDP-1 and will be clescribed in a later docwnent. SECTION 111.

DESCRIPTION OF FWCTXONS IN BBN-LISP cons[x; yl cons constructs a dotted pair of 7 SUBR x and y. If p is a list, x becomes w II the first element of thak list.

car gives the first element of a car[%] 7 SUBR list Cx, or the left element of a dotted pair _x. Nominally undefined for atoms, it gives the binding (value) of an atom _x.

-cdr gives the tail of a list (all . but the first element). This is also the right member of a dotted pair. If -x ia an atom, --cdr[x] gives the property list of 5. caar[x] = car[ carCx1 1 All 30 combinations of nested cars SUBR and -cdrs up to 4 deep are included In the system. cddddr[x] = cdr[cdr[cdr[cdr[x]]]] SUBR eq[x;yl The value of eg is T if _x and y are I SUBR identical atoms, includkng numbers; otherwise the value is NIL. (will give T for lists if their internal representations are identical, NIL otherwise. ) null[x] eq[x; NIL] SUBR atom[x] Its value is T il' -x is an atom; SUBR NIL otherwise. oblist [I Gives a list of till atms in the SUBR system. not [x] Its value is truct if its argument EX?R is false, and false otherwise. quote [x] This is a function that prevents FSUBR its argument from being evalu- ated. Its value is -x itself. cond [XI The argument for -cond is a list. FSUBR Each element of -;he list is itself a list containing n 2 1 items: the first is an expression whose value may be fall~eor true (that is, NIL, or anything which is not NIL); the rest mity be any expres- sions. This is 'the conditional expression in the LISP system. The meaning of i't is : if the first element of the first list is true (not NIL), then the f ol- lowing expressio:ns are evaluated. The value of the conditional is the value of the last expression in this sublist. If there is only one expression, then the value of the conditional is the value of this expression. This value co- incides with the value in 7090 LISP for pairs clf items, hut allows additionaJ flexibility. If the first element of the first list is false (=: NIL), then the second sublist 1s considered, etc. Thus, the arguments are searched until a first element of a list is found which 1s not NIL. If none are found, the value of the conditional expzlession is NIL. proglll This feature allows the user to FSUBR write an ALGOL4 ike program con- taining LISP sta.tements to be executed. The argument is a list, the first e1emec.t of which is a list of program variables. The rest of the list is a sequence of statements, and atomic symbols used as labels for transfer points. go[xl gg is the function used to cause a FSUBR transfer in prog . (GO A) will cause the program to continue at the label A. list[xl; . . . ;xn] The value of --liat is a list of FSmR the values of its arguments. return[x] return is the nclrmal end of a SUBR pro&. Its argument is evaluated and is the value of the prog in which it appeare .

print [x] Prints .Lx, followed by carriage SUBR return, on speci f ied devices (see punchon, Qpeout) . Value is -x. prinl [x] Prints one atom, 5, with no space STJBR or carriage retc.rn following . terpri[ ] Prints a carriage return. Value SUBR is NIL. punchon[x] Turns punch on f'or print if x = T; SUBR turns punch off if x = NIL. Value is former setting of punchon. typeout [x] If x = T, turns typewriter on for SUBR printing. If x = NIL, turns type- writer off. Val.ue f s former setting of typecut.- read [I Reads on S-expression from SUBR specified device (see typein). punch [x] This function sets punchon to t, EXPR sets typeout to nil, punches x,- and then restores punchon and typeout to their original values, typein[x] If x = T read-in device is set to SUBR typewriter. If x = NIL read-in device is set to reader. Value is former setting of typein.

ratom[] Reads in one atom from read-in de- SUBR vice. Separation of atoms is as defined by the functlona setsepn and setbrk,

setsepr[x] These are both fWBRS and may have FSUBR up to 18 argummts each. Arguments setbrk[x] FSUBR should be octal numbers, e.g., 77q for carriage return. Characters defined by --setbrk will delimit atoms and be returned as separate atoms themselves. Characters defined by setsepr will not be returned and will serve only separate atoms. Fop example, to make ratom read in ordinary format, space coma (33q), and carriage return (77q) are separation characters, and left paren (579 1, right paren (55q 1, 4 period (739) are break chara&&rs. nus setsepr[oq 33q 77~3 setbrkl57q 554 734j would set up these ~~'mcteristics. The value of -setsepr' and of setbrk is NIL, This SUBR cleare the input and output buffers of the e equence break pack- age, including the sequence break

reader, ratom, .I--Iread, arid Bpein line buffers, and the case lower case. This mearis that if you have

just done a @ read, and the S-expression did not complete1 a line, whatever else is on that line will be lost. However, it is u ery useful if you want to initialhe the system, or an error has been made, and you want to clear out what k.as been read in on a line.

If x - T, readir, sets the te-letype input. to the payier tape reader. Specifically, it eliminates the line- feed echo after a carriage return, and the delete characters, rubout and colon, are r.ot recognized. Set- ting -x to NIL restbres the status to normal. Tfiis function returns its previous value. feed [n] The value of -n nust be a number, SUBR . This function outputs on the teletype -n carriage return-line feeds or -n carriage returns depending on the setting of --readln. character[n] This function outputs on the tele- SUBR type a single character with octal representation (code) -n. -n must be a number. progl [x;Y I This function evaluates both its SUBR arguments in order, that is, _x first and then y, and then returns the value of 2. prog2[x;y I The purpose of'this function is to SUBR allow the evaluation of -x, before returning ye progn[x;y; .;zl progn is an FSUBR which evaluates FSUBR .. each of its artpments in sequence, and returns the value of its last argument as its value. It is an extension of progg. set[x;yl This function sets the atom which SUBR is the value oC -x, to the value of y, and returns the value of ye

This FSUBR is Identical to set J except that ths first argument is quoted. Example: If the value of -x is 2, and the value ~f y is 2, then set [x;y] would result in -c having value b, and b returned. setq[x;y] .L - would result in x having value 5, I and -b returned. The value of y ie unaffected. -setn requires a:ad checks for an atom as the value of the first argument, and a number as the second. If the first argument Ls -not already de- fined as a numbtar, the value of the second will be moved to a new cell in FWS (Full Wo:d space), the loca- tion of which w:lll be stored in the value cell of the first argument. Otherwise, -setn replaces the FWS cell containing the previous numeric value of the fimt argument by the numeric value ol' the second, If the

second argument was the most recent ' number added to FWS, the cell con- taining its value is returned to the free I.ist.

creates a new cell1 in EWS containing the old value of' P plus 1. This value gets moved to the FWS cell con- taining the old value.

The following will lose: (PROG .. (SET (QUOTE A) B) (SETN (QUOTE A) (PLUS A 1)) .. . ) because the cell containing the value of A is the same as that for B. To avoid the problea, the first SET should have been a SETN so that a unique numeric value cell would have been assigned for A. Identical to -se4q except that neither argument is eva luated . This FEXPR is identical to -setn except that the first argument is quoted.

putd places the value of y into the function cell cf the atom which is the value of x. This is the basic way of definirq functions. putd is

mnemonic for ~,tCIIdefinition on -x. Value of putd 1s the definition (value of y ) . putdq[x;y I This function 1s similar to putd, FEXPR but both argumenCs are considered quoted, and itfl value is 2. geed 1x1 This function gets- the -definition SUBR of the furnctioul, whose name is 'the value of x. If -x is not a defined function, the value of getd[x] is NIL; if -x is a SUBR or FSUBR, the value is a number.

This function gives EWR, FEXPR, SUBR, FSUBR or NIL depending on whether x is an EXPR, FEXPR, SUBR, m FSUBR or not defined, respectively.

\ eval [x] eval evaluates the expression x and \. S'UBR - - returns this value. errorset[ fom; arg ] This function calls -eval with the SUBR / value of -form, and returns with a list of this vrxlue if' no error is encountered. :Cf an error is encountered on the call to -eval, errorset retur~zswith the value NIL. If a- i~ T, the message from error is printed; the message is not printed if arg = NIL. ersetq[x] This FEXPR is defined as FEXPR (ERRORSET (CAR X) T); that is, it is the same as errorset with the argument quoted and the error flag set to T. nlsetq[x] This FEXPR is *Ldentical to ersetq FEXPR except that the error flag is set to NIL and the error comment from error will not be printed out. error[x] error induces inn error with mes- SUBR sage -x. quit[ I quit induces a "strong" emr, La.-, SUBR - will unwind program errorsets to the top level. equal [ x; y I The value of. tl2is function is T if SUBR -x and g are es'lal, that is, identi- cal S-expressllons , and NIL otherwise. It is as fast i3S -eq for atoms. and E x] This function is an FSmRand can FSUBR take an indefinite number of argu- ments. Its vahe is T if none of its arguments has vialue NIL, and is NIL otherwise.

-or is also an FSUBR and may have an indefinite numbl4r of arguments (in- cluding 0). -or has value NIL if all of its arguments have value NIL, otherwise, it hiss value T. rdf lxlx] If -x is NIL thi3 function will try EXPR to read one S-e:lrpression from the typewriter with read[]; if no error occurred in reading, 3.6 will return with list of the S-expression that. was read. If a:? error occurs in reading, it returns with NIL. If x is not NIL, it will attempt to read an S-expression and keep attempting to read it unti'l it gets one without an error; each time it tries to read an S-expression and gets an error, it will print out x. In this case .I it returns with the S-expression itself (not 1is.t of the S-expression). append[x;y I This function copies list -x and EXPR appends list y to this copy. The value is the combined list. nconc [x; y] This function irr similar to SUBR append, in effect, but it actual- ly causes this effect by modify- ing the list st1:ucture JC, and making the last element in the list -x point to the list x. The value of nconc ::s a pointer to

the first list .I-ir, but since this first list has now been modified it is a pointer to the concate- nated list. nnconc [x;yJ This function iri the same as SUBR nconc. nnconc :.s used by the trace programs iio that nconc it- self can be tracted. attach[x;y] This function a1;taches x to the EXPR - front the doing rplaca and an 'rplacd. tconc [x;p] This function pl'ovides an effi- EXPR cient way for placing an item -x at the end of a list E. This list is the fira~titem on 2, that is, car[p]; cdrjp] is a pointer to the last element in this list; x is placed on the end of the I list by modifying this structure, and -x is placed on the list as an item. The effect of this function

is equivalent tcj nconc [car [p] ; list [x] 1, with c:dr[p] updated to point to the element of the modified list. ~conc[x;pl This function is similar to tconc, EXPR except that 111 this case -x is a list. An entire lisl; will be tacked on the end of car[p], and cdr[p] will be adjusted to be! a pointer to the last element of thi-s new combined list. Both tconc anti lconc work correctly given null arguments. last[x] This functfon has as its value a EXPR pointer to thc last cell in the list 3 and returnz! NIL ff -x is an atom. lengthlx] This function has as a value the EXPR length of the list ux. If -...Ix is an atom, it retu19ns 0. prettyprint[x] The argument of prettyprint is a EXPR list of names of functions; it prints and/or punches (depending on the settings) the definitions of the named functions in a pretty format. It u1;ilizes the functions

printdef-9 --$ endline and superprint. This latter fttnction does all the work. prettydef [x] This function of one argument (a EXPR list of functi-on names ) prints and/

or punches " (I)=~Q", followed by

the prettyprint.. - listing of each of these functions, followed by a right paren. A tap(! punched by grettydef can be loaded by the function -load if a STOP is punched on the end of the tape. Tho value of prettydef def ine[x] The argument of define is a list. EXPR Each element of the list is itself a list containing either two or three items, In a two-item list

the first item of each element of ' the list is the name of a function to be defined, and the second item is the defini~lglambda or nlamda expression. :Cn a three-item list the first ite~nis again the name of the function '50 be defined. The second its the lambda. list of vari- ables and the third is the form for the expression. As an example consider the :Pollowing two equiva- lent expressions for defining the function null, def ineq[x; .. . ; z] This FEXPR is c:.osely related to FEXPR define. Howeve]?, it can take an indefinite numbtrr of arguments, and it will treat them literally, as if they were quoted. Each of the argu- ments must be a list of the form described as an element of the list which is the argcument for define. Usin@; def ineq instead of define allows one to e:.iminate two pairs of parentheses :in writing functions to be defined for loading with the function -load. load[x] -load is a funct:ion which reads suc- EXPR cessive S-exprel3sions from the paper tape reader, anti evaluates each as it is read. If x = T, then -load prints the valur?; otherwise it does not. -load cont:inues reading S-ex- pressions and evaluating them, until it reads the single atom STOP fol- lowed by a carr2age return, at which po5nt it return$! the value NIL. Using -load is the standard way of gettfng functiolls in from the paper tape reader; it saves having to write sequences of E(EVAL (READ)). unpack[x] The argument of unpack should be an SUBR atom. The valu~of unpack is a list which contains, in order, the char- acters which mace up the print name of that atom.

The argument 2 3f pack must be a list of atoms. The value of pack is a single atom whose print name is a packed version of the print names of all the atoms given in the list. Thus pack[ (a bc def g)] = abcdefg,

remob [x] The argument of remob must be an SUBR atom. The effect of applying -remob to this atom is to remove a1l''t- of this atom from the system. $!His is a good way of reclaiming @ace from atoms which are no losfge~m. but it 1s very dangerouw and remob should be used with cj&e. A future mention of the s~t;me~"%ltomname will have no comec-f;l& with the old one that was fdmdly there. In addi- tiorl, any/i~tswhich point to this ,old atprh ill now be incorrect.

member[x; y] pirl SUBR checks to see if SUBR x is a member of the list y. If SO, ?- 'it returns the value T; if not, it returns the value NIL. rplacd[x;yI Ttlis very dangerous SUBR places in SUBR the decrement of the cell pointed to by -x the pointer y. Thus it changes the internal list structure physically, as opposed to -cons which creates a new list element. This is the only way to get a circular list inside of LISP; that is by placing a pointer to the beginning of a list in a spot at the end of the list. Using this function care- lessly is one of the few ways to really clobber the system. rplaca[ x; y I This SUBR is sknilar. to rplacd, but SUBR it replaces the address pointer of -x withy. The same caveats which applied to uswg rplacd apply to rplaca.

This function 0.r no argument gener- ates a unique symbol of the form Annnn, in which each of the nts is replaced by a d Lgit. Thus the first one generated 113 A 0001, etc . This is a way of generating new atoms for various uses wiq;hin the system. disp[x a1 This function d:Lsplays one point on SUBR the cathode ray tube at the point whose coordinatc?~are (x;y) and re- turns T if the :.ight pen saw the displayed point, and NIL otherwise. displia [-1] The argument of this function is a SUBR list of successive x and y cmrdi- nates to be displayed. For example: displisE (I 2 1 3 i 4)l will successively display the points at coordLnates (1,219 (L3) and (t,4)* This is fasbr ,th&,*dis@-ery3ng eaetr-: of these three points individualTf I' by using dis~. logand[x; ...;z] This FSUBR will take the logical FSUBR AND of all of its argument as octal numbers aid return this value.

This function, im FSUBR, will take the logical OR,l)it-wise, of all of its arguments, iknd return this number

4x1 This FEXPR is &?fined as eval how- FEXPR ' ever, it is shorter and it removes the necessity for the extra pair of parentheses for the list of argu- ments for -eval. Thus, when typing into evalquote one can simply type e followed by whatever one would .Ic

type into -eval crnd have it + evaluated. get[x;yl This function gets from the list x EXPR the item after ';he atorny on list -x. If y is not on ';he list -x, this function return13 NIL. For example, get[(a b c d);bl = c. trace[x] This function hirs as an argument a EXPR list of names o:f functions. It changes the def':lnftion of these functions so thlit when each function is entered, the values of the argu- ments of this f~lnctionare printed; when the value of this function is computed this vcrlue is printed. Thus, trace[ (plus ratom)] gould cause pluls and ratom to be redefined so thlrt this tracing takes place. The value of trace is the value of its argument 2. The work of trace is dont? by the function tracl. tracp [ x; y I This function tc?Zls whether the EXPR function named :c wlth definition g rr has been traced, Its value is T if the function is being traced, and NIL otherwise. untrace [x] This function undoes what trace does, EXPR and res tares original of the functfon,, A word of warning: do not trace the following fimctions or you will get in an Lnfinite loop be- cause these func:tions are used within -tracl itelelf: print; cons; set; fntyp; -3evalo return; evalprirlt- ; 4car -9cdr null; @. mpc [x; fn] This function applies the function EXPR -fn to each of tkte elements of the list -x. It returns the value NIL. mapcar[x; fn] This function applies the function EXPR -fn to each of the elements of the list -x. It crea.tes a new list which is a map clf the old list in the sense that each element of the new list is the value of applying -fn to the corresponding element of the clld list. mapconc [x; fn] Identical to magcar- except that it does an nconc instead of a -* -cons, mapcon[x; fn] Identical to maplist- except that it does an -- nconc instead of a cons, map [x;fn] This function applies the function EXPR fn to successive tails of the list x. ..I) - That is, first it computes fn[x], and then fn[cdr[x]], etc. until -x is NIL. This function returns NIL, maplist[x; fn] This function computes successively EXPR the same values that map computes; it forms a new list consisting of successive values - of applications of this function. assoc[x;a] If -a is a list ~f dotted pairs, $hen EXPR assoc will prodme the first pair whose first Itan is x. If such an U item is not found, assoc will return NIL.

The function --sassoc searches y, which is a list of dotted pairs, for a pair whose first element is -x. If such a pair is .Found, the value of sassoc is this :?air. Otherwise, the function -u of no arguments is taken as the value of sassoc.

COPY [XI This function miskes a copy of the EXPR list 2. The value of copy is the location of the copie 11st . intersection[x; y] This function :?eturns with a list EXPR whose elements were members of both lists -x and y. union[x; yl This function :is entered with two EXPR lists. It returns with a list con- sisting of all elements included on either of the ';wo original lists. If the same itern is a member of both original lists,, it is included only once on the new list, propLx;y;ul The function pi?oz searches the list EXPR -x for an item :;hat is equal to y. If such an ele~rlentis found, the value of prop :is the rest of the list beginning immediately after that element. Othelwise, the value is u[], where u- kd function of no

This is a W;bn to reverse-Jthe' top level of a list, JZ¶ms, nsTTfg reverse on (A B (C D)) = ((c D) B A) subst[x;y; z] This function gives the result of EXPR substituting the S-expression -x for all occurrenceci of the atomic symbol y in the S-explaession -z. s~blis[x; y] Here -x is a list of pairs: EXPR ( (ul*vl) (u2*v2) a ' (un*vn))

The value of sublis[x;y] is the results of substituting each -v for the correspo:nding u in x, .I evala [x; a] This is the regular -eval in the SUBR 7094 LISP. Its first argument is a form which is lwaluated by using the values obtai:ned from 2, a list of dotted pairs. That is, any variables appearing in -x that also appear on -a will be given the value indicated (on -a. apply[fn;args;a] apply applies the function -fn to SUBR the arguments ar~pwith the values obtained from 5, i.e. the argu- ments of -fn on -a:= are -not evalu- ated but given to -fn directly. -a is used to eva:Luate free vari- ables in -fn as described above. remove [x; l] The function remove removes all EXPR -- occurrences of -x from list -1, remprop r x; YI This function --rernoves all occur- EXPR rences of the progerty with label from the property list of -x. put[x;y;zI This function @;s on the property EXPR list of x, the label followed by -..) the property -z. The current value of -z replaces any previous value of 5 with label JT on this property list, add[x; y; z] This function addis the value z to L - EXPR the list appearing under the prop- erty on the atom -x. If -x does not have a property E, the effect is the same as puat[x;y;list[z]].

This function @;et,s the groperty with label from the property list of -x. NOTE: Both prop i%nd get may also be used on property .Lists. However, since getp search13s a list two at a time, the latter allows one to have the same 0bjl3ct as both a property and a value. e. g., if the property list of -x is (PROP1 A PROP2 B .4 C) then geC[x;A] = PROP2, but getp[x;.I] = C.

def list [x; ind] This function is med to put any EXPR indicator or1 a prl~pertylist. The first argument is a list of pairs (where the first ~f the pair is a name and the secoind party of the pair is the property to be stored with the indicato:~on the property list of the name) and the second argument is the i~zdicatorthat is to be used.

select [x;yl;y2 8*e;yn;z1 An example of arguments for this FSUBR function is: The qits are eval'lated in sequence until one is foun13 such that qi = q, and the value ~f select is the value of the corresponding ei. If no such qi is found the value of select is that of e.

selectq[x;y;z] selectq is identi~alto select ex- FSUBR cept that the qits are not evalu- ated-only q. time[x n] This flulc$ion per forms computation EXPR x n times and indicates average time -LI of' gcgagrx1 If x=T garbage collector will SUBR print message when entered. If x=NIL, no message is printed.

reclaim[] This function initiates a garbage SUBR collection and returns with the nwnber of available LISP words in free storage.

field[n] This function calls field -n from SUBR the drum. (See description of system program linking.)

nth[x;n] This EXPR has as inputs a list .-x EXPR and a positive integer -no Its value is a list whose first element is the -nth element of list -x., Thus if -n = 1, it returns the list -x it- self. If n = 2, it returns cdr[x] . If n = 3, it returns cddr[x], etc. editf [x] This EXPR gets the expression EXPR which is the deffnition of the -function named -x and gives it to edite. editv[x] This EXPR gets the value of the C EXPR atom -x and gives it to edite for editing . editp[x] This EXPR gets tk.e -property list of EXPR the atom x, etc .IcI . edite[x] This function is the executive for EXPR an editing facility for LISP ex- pressions. The z.rgument of edite must be a list tc) be edited. When edite has been ca.lled, it prints out EDIT, and thein waits for input from the on-line teletype (or the reader if typein is set to NIL). The input that ma~ybe typed in may be a positive inl.eger, a negative integer, or zero, or one of these as the first element of a two- element list, or NIL, or one of several special lists described below. Typing irk NIL terminates editing. This editing pro6;ram allows you to edit any subexpre!ssion within the current level expression, that is, you can replace or delete any sub- expression of this expression, or insert anything before any subex- pression of this expression. An input (n- exp) where -n is a positive integer will replace the nth expres- sion in the current level expression by exg; if -n is a negative integer it will put exp just before the -nth subexpression in the current level expression. (n) where -n is a posi- tive integer (with no expression following this integer) will delete the -nth expression. Warning: Typing ' (1)", where current expression is a kiingleton, will not have desired effelct. I An input of 0 will take you up to the next higher level expression. If the input to --edit is a positive integer, the nth-subexpression of the current expression will become the expression that can be edited. An important thing to note is that all editing is final in the sense that any changes that are requested are put in with alacas and rplacds. It is the original expression which has been modified to give the edited version; to return to the original expression you must re-edit. How- ever, by using the COPY and RESTORE feature, the user can protect him- self against errors in editing. The function edite calls edit% edit2f, edit2af; and edit3f-b do all the work. Other special commantis are: COPY copies and saves entire expression being edited as it currimtly exists. RESTORE Restores e:rpression as of last co])y: the current level expression will be this current level expression at last copy RESTORING tvithout copying will have 110 effect. P same as (d 0). (p n) Prints the -nth subexpres- sion of the current ex- pression to a level of 2, using LEVEILN described be- low. If n is zero, prints current exl~ressionto level 2. (p n rn) Prints nth subexpression to a level m. All printi.ng may be lnterupted. (N el e2 '.*) which will tack the expressions el e2, . . . to the end of the current expression, (E exp) will print the value of eval [exp] . 6 n exp) will compute v = eval[expJ and then act as if edit were given (n vll. This allows you to insert the va:.ue of a compu- tation in the currenl; expression, at subexpression -n. (n- must be a num- ber) . (LI n) will insert 1% left parenthesis immediately before subexpression .I-n in the current expr~sssionand a match- ing right paren at -the end of this current expression. For example, if e = (A B C) (LI 2) yields (A (B C) ) . (LO n) will remove .z left paren from the -nth subexpression, and take a corresponding right paren from the end of the current expression, e.g., for e = (A (B C) D) (LO 2) yields (A B C) (RO n) will remove a right paren from the -rAth subexpression of the current expression, and insert one in at the end of the current top level expression, e.g., , for e = (A (B C) DE) (Ro 2) yields (A (B C DE)) (RI m n) will insert a right paren

in the I_nth subexpression of the -mth subexpression of' the current expres- sion, removing one from the end of the subexpression, for e = (A B (C D E) F) (RI 3 1) yields

Abbreviates list x at level n, using the symbol ampersand, "&," to indi- cate greater depth. For example, leveln [ (A (B C) (D (E F) G) ) 21 is (A (B C) (D & GI). The following 9 functions form a Break Packag~swhich allows the user to make a break conditional u-pon the reslllt of some computa- tion and thus arrest the operation of a function. He may interro- gate the broken function as to the current values of its arguments or other variables, or perform arbitrary LISP computations; then he may return with a specified value for it without actually entering it. Alternatively, the user may just "crack" a function, Leo, print out the result of some computation before executing the function and print out the final value of this function.

"-break[ f n; when; what ] break is a funztion of three argu- EXPR ments: the functlcrn to be broken, under what con5ition to break, and what to print 3ut when a break occurs If -when = T, tne function always breaks. If --when = (NIL) a crack is made in -fn. If -what =NfL, no information is printed out. break_ - redefines -fn using breakl so that @- the time the F~nctionwould have-" been entered, :weak%is *entered instead with the definition of the function and i:2f onnation regarding the conditions for breaking. unbreak[ fn] unbreak redefijies fn as it was before EXPR - the break and *returns the value -fn. If -fn is not broken when unbreak is called, the va:Lue of unbreak is (FN NOT BROKEN) . breaklist [I] breaklist is a function of one argu- FEXPR ment, a list of function names. It performs (BREAK Fq T NIL) for each function name and returns the list of values of --break. Note that (BREAK FN T NIL) will cause -fn always to break, and will not print out any special message, unbreaklist [ 1] This function performs (UNBREAKFN) FEXPR for each function on the list -1. breakat[fn;where;when;what] This functfon is similar to break EXPR except that instead of inserting a break at the begfnning of -fn, it allows the user to Insert a break at any top-level place in The argument -. where indicates the label or statement at which the break is to occur. The other arguments are used as fn --break. unbreakat [ fn; where] This functfon removes break EXPR serted by --breakat. breakprog[ fn; l] breakproq is entered with the name EXPR of a function and a list of places . in that function where a break is desired. -breakprog perf orma (BREAKAT FN WH:ERE T NIL) for each place on the list 1. unbreakprogl fn] This function perf oms EXPR (uNBREAKAT FN WHERE) for each place where a break exists in 3. breakl[form;when;fn;what] Although this function is not FEXPR entered direc1;ly by the user, it is the heart of ;tll the break functions and is entered when a break occurs. After the spec:ified information is printed out, !)reakl listens to the typewriter or teletype for inputs. ~f STOP is input', a normal, exit f s achieved. If RETURN FOO is input --break1 returns (EVAL FOO). If .QmT is :.nput, it performs (ERROR FN) . :Cf EVAL is input, it evaluates -fn. If a nomnal exit Is subsequently trchieved via the STOP command, break1 does not reejraluate -fn, but uses 1:he value obtained by the coumand. The EXAL feature is ust?ful for evaluating a broken function without "letting go" of the break, e.g., to examine tlhe effect of executing a broken furac- tion. If OK :.s input, a normal return is mad(: without printing the value of the l'unctfon. Any other input to --breakl is evaluated, and its value prirlted. This function uses bp2 to dc) part of its work. Arithmetic Functions (all arguments must be? numbers) greaterp[x;y I T if' x > y; SUBR NIL otherwf sc: lessp[x;yI T if x < y; EXPR NIL otherwisc! zerop[x] T if x is zez*o,o EXPR NIL otherwise! ' minusp[x] T if x is neg;ative; EXPR NIL otherwfse! numberp[x] T if' x is a number; SUBR NIL otherwise! addl[x] EXPR

plus[x;yl x + y his FSUBR may have any FSUBR number of arguments.) minus [x] SUBR times [x;y] product of x and y (This FSUBR FSUBR may kave any number of argun.ents .) quotient [x; y] greatest integer i:n quotient x/y sm difference [x; y] This function has for its value the EXPR algebraic differenl?e between its arguments. remainder [x; y] This function comp'utes the number EXPR theoretic remainde r for f ixed-point numbers. divide [x;y] This function yiel~isa dotted pair SUBR whose first member is quotient [x;y] and whose second member is remainder [x;y] . Remainder .Ls defined in terms of divide. Following is a list of all atoms with AI?VALts (per- manent .yalues) in the basic system and *;heir values. blank space space space tab tab

eqs ign xeqs nil nil nil period plus lpar war slash t *t* qmark xdol xsqu xdqu xlbr xrbr xarr uparr colon xgreater xlesser xnwn xper

%a*. SECTION IV.

LISTINGS OF S-WPRESSXONS OF EXPR 'S AND FEXPR ' S

(prog nil ( cond ' '[ (quote putdq (quote (quote pro 2

(return [iambda (x)

(cond (quote (return

(cond

(assoc (lambda (xsas sas) (cond 1in71 ysasr nil) e ual (cam ysas) xsas t assoc xsas (cdr ysas (attach (lambda (x y) (rplaca (rplacd Y (cons (tip Y) (c& Y) ) ) XI))

(deflis t (lambda ( 1 ind) (prog loop (cond ((null 1) (return nil put (caar 1) ind (cadar setq 1 (cdr 1) 80 loop) 1) 1 (difference (lambda (x y) (plus X (minus ~1))) (e (nlamda (xeeee) (eval xeeee ) ) ) (ersetq (nlamda (ersetx) (errorset (car ersetx) t ) ) ) (x Y) (prog (2) (setq z (cdr x)) loop ( cond

(intersection ( cond nil) . car x) y) (cons (car x)

(c@ x) Y))))) ( last (lambda (x) (pro65 (xx) 1 ( cond ( (atom x) (return xx) )) setq xx x) 1;Et14,il XI

( lconc (lambda (6 P) (prog (=I

xx (last x))) (trrror (list (quote**a lconc) ) (cons x xx) ) car p) ) (rplaca (rp3.acd p xx) x)) ( t prog2 trplaod (cdr (rplacd P =I ( length ( lambda X) (prog fn) (setq n (1 (cond ( (atom x) (return setq x cdr x) /5t1P,i11add' "11

(lesSP ( lambda (x y) (cond

- - (lambda (mapcx mapcf ( (null mapcx) nil mapcf (car mapcx) ) ImaPC (car mapcx) mpcf))))))

(mapcar mpcrx) mpcrf

lambda (mpcnx mpcnf (null mpcnx) nil t (nconc (i3pcnf (rnapcon mpcnf \ \

(mapconc (mpcncx mpcnc cond mpcncx) nil

t (nconc (rnpcncf I mpcncx) ) ( cdr mpcncx) mpcncf

(mpla tx mplstf ) (cond (null mplstx) nil) t (cons (mplstf mplstx) (maplist (car mplstx) mplstf

(minusp (lambda (x) (greaterp 0 x) ) ) (nil1 (nlamba (xnil) nil)) (nlsetq (nlamda (nlsetx) (errorset (car nlsetx) nil) ) ) (not

(punch (lambda (prog (Y 2) setq y punchon setq z I typeout print x) punchon y typeout z return x) I)) (put (lambda (x y z) (prog nil - loop (cond- -- ( (ndl (cdr x) ) (rplacd x (Xist

equal (cadr x) ) (rplaca (cddr x) z) ) setq x (cddr x) 3 (go 1oop:l))

(rdf lx

(X (go rl)1) (setq xx (ersetq (read) )) cond ( (setq xx (nlsetq (read))) (setq xx (csr xx (remainder (lambda (x y) (cdr (divide x y)))) (remove (lambda (a x) (cond null x) nil) a (car x)) (remove a (cdr x (car x) (remove a (cdr x) ) ( remprop (lambda (x y) (prog nil loop x) 1 cadr x) ( cdddr

(reverse (lambda (4 (prog (4 loop (cond

(setnq ,,,f nlamda (xsetnq) (setn (car xsetnq) (eve.1 (cadr xsetnq) (setqq (nlamda (x) (set (car x) (cadr x)))) ( soundexin (nlamda (x) (lambda (yadx) (put (soundex ysdx) (quote ( soundexout (lambda (x) (getp x (quote name)))) (sub1 (lambda (x) (plus "- (sub2 (lambda (a z) (cond ((null a) z) e ual (cab a 1't 4sub2 (cdr a (sublis

( subst

(car 2)) (subst x y (cdr 2))))))) (tconc

setq xx (coris x nil) ) xx) )

(time (lambda

(clock)

setq y eval x /set, .[sub1 m] { go tl)))) (setq m (divide (plus (minus c) ) n) ) (prinl (car m)) prinl period) prinl (quotient (times (c* m) prinl blank) print (quote seconds) ) I return Y)) 1) (union

y) (union (cdr (union (cdr x) (zerop (lambda (x) (equal x 0)) ) (break (lambda (fn when what) (prog (xx yy zz) ( cond fn) ) ) (return (prog2

(quote breakl) nil when (setq xx (list fn (qucte (undefined.)) ) ) what) 1) =))I ( (eq (setq yy (fhtyp fn) ) (qt.ote fsubr) ) (return (cons fn (quote (is an fsubr)))) ) ( (null (eq YY (quote subr) ) ) (setq yy (rdflx (print (cons fn need =es)))))) putd (setq zz (gensyrn) ) xx) setq xx (putd fn (list I (quote lambda) YY (cons YY)))) (cond ( (eq (caaddr xx) (quote breakl)) (sea xx ( list

(putd fn (list car xx) cadr xx) list quote breakl) caddr xx) when (list fn) (return fn I11 (unbreak (1- (fn) (pro (aYY) (return !! cond ((null (setq xx (getd f'n))) (cons fn (quote (not a function)-))) ( (and . - ( (eq (setq YY (fntyp fn)) (quote expr)

fi) (t (cons fn (quote (not broken)))')))))) (breaklist (nlamda (x) (maplist x (quote (lambda (x) (break (car x t nil)))))) (unbreaklist a (x) (maplist x (quote (lambda (x) (unbreak (car

(breakprog (lambda (bpx bp bpy (quote (Lunbda (2) (breakat bpx (car z) t nil (unbreakpro (lambda ?x) (prog xx) (setq xx I bpi x)) ul ( cond (quote break:l)) (rplacd xx (cddr (setq xx (cdr =)I (go ul)) t (return nil) 1) ~1)))) ( breakat (lambda (fn where when what) (prog (a) setq a (bpl fn)) bl I oond ( (e ual (car a) where) (return (prog2 bpkacci a (cons (list (quote brealcl) nil when (list fn (quote at) where) what) (cdr a)) ) where 11 ((setq a8(cdr a)) (go bl))) (return cons where (quote (not found)))))))

ul

(not broken at )) (list

found) ) ) ) ) ) )

(bpi (lambda (x) (pro8 (xx) (return (cond

eq (setq xx (fntyp x ) (quote expr)) eq xx (quote fexpr) ) (caaddr (setq xx (getd x))) (quote prgg 1)) (cad& =)I (t (error (cons x (quote (not a program) ) ) ) )))))I (prog (4 setq a (punchon t prinl (quote u(N) (print (quote define

(prettyprint (lambda (1) (map 1 [quote (lambda (j) (prog (tl)

(t (quote undefi

(printdef (lambda (e) (prog (iiunit iunitl) setnq 1 1) setq iunit (quote "1) Isetq iunitl 3) prinl iunit ) Isuperprint e t return nil)) (su erprint flambda (e) (cond ((atom e) (cond ((member e (quote

I rt.n rr u 1)) (prinl (pack (list (quote In)

setq ep e) I prinl lpar)

T,, I 1, I. I 11, I/ 11 I i/ 11, I 11 ( cond ( (member (car ep) (quote (and or select selectq list plus times cond

(. (or. caar ep quote lmnbda caar ep quote n.Lamda superprint (car ep) ) sew eP (c* ep) I( cond null ep return (prinl rpar))) [latom epl Igo *dl)) setnq i (subl i)) prinl blank) prinl period) Iprinl blank) prinl ep) return (prinl r ar)) Isetnq i (addl if; ) superprint (car-ep) ) Isetq eP (c@ ep) ( cond

(superprint (car ep) ) setnq7i (subl i)) return (prinl rpar) ) prinl (car ep)) setq ep [cdr ep]j aetnq i add1 i ( cond

( cond (cond ep) (go pz) 1) prinl iunlt prlnl funit (setnq i (plus i 2)\ sup&&rint (car ep) ) setnq i (plus I i

prinl (car ep)) setnq m (plus igoiunitl""' iuni tl (minus (length (unpack (c ar ep) ) ) ) ) ) (setnq m (sub1 m) ) prinl blank) cond ((null (or - zerop m)

( cond

(endline

( cond (return (error (trace (lambda (x) (pro$ (a b c g) (setq a x)

L B ( (null x) (return a) ) ) (setq b (getd (setq c (car x) ))) (setq x (cdr x) ) ( cond w.defined)

print (cons c (quo was traced 80 loop) 1) setq a (gensym) 1 b c (list - quote nlamda 1 e tracl) (quote quote) c) (list (quote quote)

(untrace (lambda (x) (prog (a b c ) set (quote a) x loop [cond 7

(cond (set (quote b) (g~!tdg) )) (progn uote b) (cdaddr b) ) cadar b) (getd (set (quote c) (cadadr

g (quote (not traced)))))) (x y) (and fntyp x) (quote fexpr) caaddr y) (quote tracl

(lambda gtrac xtrac) print (cons ctrac with)))) set (quote ( (eq (fntyp f s~br)) (print xtrac ( (eq ( fntyp gtrac) (quote f e~pr)) (print xtrac (t (evalprint xtrac) ) ) ) set (quote atrac) eval (cons gtrac xtrac) ) ) print (cons ctrac Iquote (has vaue)))) (returnI (print atrac) ) ) ) ) ( evalprint ( lambda (xvalp) (prog (avalp) * . ( (null xvalp) (return avalp) ) ) (set (quote avalp) (nnconc avalp (list (list (quote quote) (print (eval set (quote xvalp) xvalp go loop)) 1) (editf (lambda (x) (prog2 utd x (edite (getd x)) )

(editv (lambda (x) (pro@ (set x (edite (eval x))) XI)) (editp (lambda (x) (pro@ (r lacd x (edite (cdr x) ) ) 471 (edite

1 (print (quote edit) ) ( cond null (ersetq (setq c (read))) null c) (return (car (1ast:r 1 numberp c) (editlf c)) eq c quote copy) 1 (setq Y (COPY 1))) eq c I quote restore)) (setla 1 (cond 3f (quote 1 t2f c'))

(editlf (lambda (c) (cond ((eq c 0) (cond (null (cdr 1)) ( rint qmark) ) 1 1 # lcdr D t (sets P ))I) th (car 1)))(pr:.nt qmark (nth (car 1) c)) 1))) (lambda (c) (cond ( (greaterp (car c) o ( (greaterp (car c 1 Pondlength (car 1)) ) (print qmark (subl (car c) ) (car 1) (cdr

(car c)) (length (:car 1)))) (print (subl (minus (car c))) (car 1)

(edit2af (lambda (n x r d) (prog2 (cond ((null (eq n 0)) (r (nth x n) (nconc r (cond d cdr (nth x ny [t [oddr (nth x n 1) (car r) x (cadr(car x) rl

(lambda x) (cond ((eq [car x) (quote 1)) (edit2f (list (eval (kaddr x) ) ) ) (ersetq (printl (eval (cadr x \\\\\ ((es (car x) (quote e f (nconc (car 1 (c* XI)) member ri ro (errorset (nconc quote ((car (t (print (bpnt (hmbda (x) (prog (Y n) (cond zerop (car x)) (setq y (car 1) ) greaterp (car x) (length (car 1

(anup (car x) (go bl) ) t (sets y (car (nth (car 1) (car x) 1)) 1) (cond

- -. (return (cond (nlsetq (print n)) ) nil) [t (print (quote (return (print qmark) ) ) ) (leveln

(x) (leveln x (subl n)))

(nth

(nth (cdr x) (subl n)) )

(lastr (lambda (x) (cond null x) (error (null list)) ) ) null (cdr x) ) x I' t (lastr (cdr x)

APPENDIX A .1

LISP LOADER

The LISP loader allows one to load several drum fields from either paper tape or magnetic tape. In addition, there is provision for transferring a system from drum to mag tape. A complete system is treated as a file on tape (each core load is one block of the file) and all tape commands are in terms of files rather than blocks. Teletype should be connected to channel 0 of the 630 scanner.

Instructions for Loading System Programs onto the Drum

The LISP loader can be used for setting up the dmfields of the system programs, including itself. To do this:

1. Read into core 1 the system program to be placed on a drum field.

2. Read into core 1 the program at location 0 for that dmfield.

3. Read into core 0 the LISP loader.

4. Type: nd where n is the octal number of the drum field onto which to dump core 1.

Instructions for Loading LISP with the Loader-

1. Load mag tape of system on tape drive and set it to automatic on unit 1. A.1-1 2. Read into core 0 the paper tape of the LISP loader. The mag tape will be rewound and the LISP loader will be waiting for typein. (The LISP loader starts at 300. ):

3. Type: nr where n is the octal number of the flle to be read in. 26 drum fields will be read off of tke mag tape onto the drwn and the typewriter will type out n m where n is the first block number read (starting with 0) and m is the last +1 block number read,

4. Type: 1

' This will take the user to LISP.

Instructions for Writing LISP onto Mag %&'with the Loader.

1. From LISP call the drum f'ield with the LISP loader, FIELD (25~), or read into core 0 the paper tape of the LISP loader,

2. Type: nw where n is the octal number of the file that you wish to write. List of Commands Available in the LISP Loade:? (n is an octal number)

calls -LISP calls the -editor on field 26 -reads onto the drum from ]nag tape file n nw -writes current drum syste~non mag tape file n nd -dumps core 1 onto relative drum field n reads relative drum field n into -core 1 Ereserves core 0 on re1at:ive drum field n gets registers 0-177 on relative drum field n and transfers to 11 selects the mag tape unit to be used. 'II. Starting the program at :3OO automatically selects unit 1, sets the -base field on this drum to n, i.e., dmloading will begin on field n from either core or mag tape. The ba~eis initially set to 1. The first relative field n is 1, not 0. Rel.ative field n is absolute field 11n - I -t- base". sets the number of -fields in a file. This value is initially set to 26 octal. rewind brigin) -space tape n files forward (or backward if n is negative). If n is ze:m the-tape-will be moved to the beginning of Ule current file. Spacing backwards has bee11 known t- trouble. Error Printouts

nOf tried to reference file 0 or drum field 0 (either absolute or relathre) file error -- while searching for a designated file, a file longer than 64 blocks was en- countered. una tape unit not available. If this is the first thing that happens l.t is because the ' program has attempted to rewind unit 1 and cannot for some reason. pmc n bad parity or missed charz.cter on reading or checking tape block n nch saw no characters for 6 iriches ept saw tape end point wcf n write check failure mag ts.pe block n drf n drum read fail, absolute f'ield n nem no end mark has been entered dwe drum write error APPENDIX A. 2

USING LISP FROM THE COMPUTER ROOM TEL-E

To use LISP from the computer room teletype: Connect the teletype to channel 0 of the scanner and then load the LISP system as described in Appendix A .1, LISP LClADADER. The teletype will carriage-return and be waiting for input into evalquote.

Manual restart should never be used as there are no known ways to cause the system to halt or crash (if either does occur, record all particulars and deliver to D. ~urphy). The following, however, do exist:

start 202 reinitializes all sequence break routines and rea tarts

start 203 APPENDIX A.3

USING LISP FROM A REMOTE DATASET

To use LISP from a remote dataset: The LISP system should be loaded and running as described in Appendix A. 1, LISP LOADER. Then :

Set the channel 0 dataset phone to "auto" (the channel 0 phone is the one on which the number 491-5120 appears).

From the remote dataset, push the "tel" button, and when the dial tone is heard in the attached receiver, dial 491-5120. The phone in the computer morn will be answered automatically, and a tone will be transmitted. When this tone is heard, the "ORIG" button shoul9 be pressed, establishing the connection.

Special Codes for Control (see standard chsrt of teletype codes for complete set)

Octal Cod.e Character 3Func t ion - - rubout deletes-the line being typed in types out and deletes the last character type13 in

break key causes an interrupt followed by an untrace. A sezond depression of this key halts the untrace. Octal Code Character Function

204 control D HANGUP, when transmitted by either computer or usper, causes immediate hangup on both ends

control G

control I Horizontal tab, on output only., causes carriae:e to be moved to . . next predefined tab stop

./ 4' control Q'". reader on: starts pager tape reader if tape! i~xoaded

.Ic.

control S reader off: when appearing on paper ta& on1 y, causes reader to stop after reading next character APPENDIX B INDEX TO FUNCTIONS name of function add add 3- and append apply assoc atom attach break break 1 breaka t breaklist breakprog car,cdr, (etc) character clearbuf cond cons COPY define def ineq deflist difference disp displis divide e edite name of description rune tion sectf on ILL, page editf editp editv

error errorse t ersetq eval evala feed field fntyp gc er;ag gen sym ge t ge td getp go grea terp intersection last lconc length lessp leveln list load logand name of descriptf on listing ITEiEEEn section =I, page -sc?c ti-page

ma pc on mapconc maplist member minus mlnusp nconc nnconc nlsetq not nth null numberp oblist or pack plus pre t tydef prei;typrin t prin 1 print

punch punchon PU .t; name of description listing runc tion sectian 111, page -SIX timpagc putd putdq quit quote quotient ra tom rdflx read readin reclaim remainder remob retnove remprop return reverse rplaca rplacd sassoc seleci; selec tq set se tbrk se tn ae tnq setq setqq setsepr sub.1 sublis subst name of description listing function sectiqn 111, page slzcticn IV, page .L tconc terpri time times trace tracp typein typeou t unbreak unbreaka t unbreakl ist unbreakprog union unpack untrace zerop Securitv Classification DOCUMENT CONTROL DATA - R&D I (Security classification of title, body of abstract and indexin& annotation must be entered when the overall report is classified) I I1. OQIGINATIN G ACTIVITY (Coworate author) 2a. REPORT SECURITY C LASSIFICATION Bolt Beranek and Newrnan Inc. I Unclassified I I Cambridge, Massachusetts

I The BBN-LISP System 4. DESCRlPTlVE NOTES (Type of report and inclusive dates) Scientific Report No. 1 5. AUTHOR(S) (Last name, first name, initial) Daniel G. Bobrow, D. Lucille Darley, Daniel L. Murphy, Cynthia Solomon, Warren Teitelman

6. REP0 RT DATE / 7r.' TOTAL NO. OF PACES 1 -7b. NO. OF REFS February 1966 82 0 8a. CONTRACT OR GRANT NO. 9s. ORIGINATOR'S REPORT NUMBER(S) AF lg(628) -5065 - ARPA Order b. PROJECT No. NO. 627 BBN Report No. 1346 8668 c. 9 b. OTHER REPORT NO(S) (Any other numbers that may be assigned this report)

d. AFCRG66- 180 10. A VA ILABILITY/LIMITATION NOTICES Distribution of this document is unlimited

11. SUPPLEMENTARY NOTES 12. SPONSORING MILITARY ACTIVITY ARPA Order No. 627, dated Hq. AFCRL, OAR (CRB) 9 March 1965. United States Air Force Redford- 13. ABSTRACT This report describes in detail the BBN-LISP system. This LISP system has a number of unique features; most notably, it has a small core memory, and utilizes a drum for storage of list / structure . The paging techniques described here allow utili- zation of this large, but slow, drum memory with a surprisingly small time penalty. These techniques are applicable to the design of efficient list processing systems embedded in time- sharing systems using paging for memory allocation. *

Unclassif Led Security Classification Security Classification 14. LINK A LINK B LINK C KEY WORDS ROLE WT ROLE WT ROLE WT LISP List Processing Language Paging Systems Drum Systems for List Structure List Structures Symbol Manipulation Language

INSTRUCTIONS I. ORIGINATING ACTIVITY: Enter the name and address imposed by security classification, using standard statements of the contractor, subcontractor, grantee, Department of Dt such as: fense activity or other organization (corporate author) issuing "Qualified requesters may obtain copies of this the report. (1) report from DDC " 2a. REPORT SECUIitTY CLASSIFICATION: Enter the ovelc (2) "Foreign announcement and dissemination of this all security classification of the report. Indicate whether report by DDC is not authorized." "Restricted Data" is included Marking is to be in accord. ance with appropriate security regulations. (3) "U. S. Government agencies may obtain copies of this report directly from DDC. Other qualified DDC 26. GROUP: Automatic downgrading is specified in DoD Di- users shall request through rective 5200.10 and Armed Forces Industrial Manual. Enter 't the group number. Also, when applicable, show that optional . markings have been used for Group 3 and Group 4 as author- (4) "U. S. military agencies may obtain copies of this ized. report directly from DDC Other qualified users 3. REPORT TITLE: Enter the complete report title in all shall request through capital letters. Titles in all cases should be unclassified. t P If a meaningful title cannot be selected without classifica- . tion, show title classification in all capitals in parenthesis (5) "All distribution of this report is controlled. Qual- immediate1y following the title. ified DDC users shall request through t ' 4. DESCRIPTIVE NOTES If appropriate, enter the type of report, e. g., interim, progress, summary, annual, or final. If the report has been furnished to the Office of Technical Give the inclusive dates when a specific reporting period is Services, Department of Commerce, for sale to the public, indim covered. cate this fact and enter the price, if known. 5. AUTHOR(S): Enter the name(s) of authods) as shown on SUPPLEMENTARY NOTES: Use for additional explan* or in the report. Enter last name, first name, middle initial. tory note& If military, show rank and branch of service. The name of the principal author is an ahsolute minimum requirement 12. SPONSORING MILITARY ACTIVITY: Enter the name of the departmental project office or laboratory sponsoring (pay 6. REPORT DATE: Enter the date of the report as day, ing for) the research and development. Include address. month, year; or month, year. If more than one date appears on the report, use date of publication. 13. ABSTRACT: Enter an abstract giving a brief and factual summary of the document indicative of the report, even though 7a. TOTAL NUMBER OF PAGES: The total page count it may also appear elsewhere in the body of the technical re- should follow normal pagination procedures, i e., enter the port. If additional space is required, a continuation sheet shall number of pages containing information. be attached. 7b. NUMBER OF REFERENCES Enter the total number of It is highly desirable tha' the abstract of classified reports references cited in the report. be unclassified. Each paragraph of the abstract shall end with 8e. CONTRACT OR GRANT NUMBER: If appropriate, enter an indication of the military security classification of the in- the applicable number of the contract or grant under which formation in the paragraph, represented as (TS), (s), (c), or (U). the report was written. There is no limitation on the length of the abstract. How- 8b, &, & 8d. PROJECT NUMBER: Enter the appropriate ever, the suggested length is from 150 to 225 words. military department identification, such as project number, 14. KEY WORDS: Key words are technically meaningful terms subpmject nunher, system numbers, task number, etc. or short phrases that characterize a report and may be used as 9a. ORIGINATOR'S REPORT NUMBER(S): Enter the offi- index entries for cataloging the report. Key words must be cia1 report number by which the document will be identified selected so that no security classification is required. Identi- and controlled by the originating activity. This number must fiers, such as equipment model designation, trade name, militaq be unique to this report. project code name, geographic location, may be used as key 96. OTHER REPORT NU=ER(S): 11 the report has been words but will be followed by an indication of technical con- assigned any other report numbcrs (either by the oridinator text. The assignment of links, roles, and weights is optional. or by the aponsor), also enter this number(s). 10. AVAILABILITY/LIMITATION NOTICES Enter any lim- itations on further dissemination of the report, other than tho=

Security Classification