y;T~adar[~]';hCompositions of - car and - cdr arise so frequently that manyexpressions can be written more concisely if we abbreviatecadr[x] for car[cdr[x]],caddr[xf for car[cdr[cdr[x]]],etc.Another useful abbreviation is to write list[el;e2; ...; e ]nfor cons[el; cons[ep; ...; cons[e,;~~~]. .. I]. This functiongives the list, (el,. ..,en), as a function of its elements.The following functions are useful when S-expressions areregarded as lists.1. append[x;y]append[x;y] = [null[x] @ @ cons[car[x];append[cdr[x];y~An example isappend[ (A$); (c,D,~)l = (A,B,c,D,E)1)2. among[x;ylThis predicate is true if the S-expression x occurs amongthe elements of the list y. We haveamong[x;y] = -null[y] h[equal[x; car[y] ]vamong[x; cdr[y] 1 13. pair[x;ylThis function gives the list of pairs of corresponding ele-ments of the lists x and y. We havepair[x;y] = [null[x] hnull[y] -+ ~~b;~atom[x]An example isA-atom[y] -+list[car[x];car[y]];pair[cdr[x];cdr[y] 1 ]]pair[ (A,B,c>; (x, (y,z),u)I = ((~3x1, (B, (Y,z)), (C,U))4. assoc[x;y]-one of the uts then assoc[x;y] is the corresponding v.assoc[x;y] = [caar[y] = x @ assoc[x;cdr[y]If y is a list of the form ( (u1,vl), . . . , (un, vn) ) and x iscons[We have1 ]-An example isassoc[x; ( (w, (A,B> 1, (x, (c,D) ) , (Y, (E,F) 1 11 = (0)5.. sublis[x;y]Here x is assumed to have the form of a list of pairs
z;eq[caar[x];z]sub2[x;~];~((u1,vi) . . , (un,vn)), where the uts are atomic, and y may beany S-expression. The value of sublis[x;y] is the result ofsubstituting each v for the corresponding u in y. In order bodefine sublis, we first define an auxiliary function, We haveandWe. havesub2[x;z]h= -+ [null[x] + cadar[x];~+ sub2[cdr[x] ; z 1 .]sublis[x;y] = [atom[y] -+cons[sublis[x; -+y] I;sub~is[x;cdr[yll11car[e, Representation of S-Functions by S-ExpressionsS-functions have been described by M-expressions. We nowgive a rule for translating M-expressions into S-expressions,in order to be able to use S-functions for making certain computationswith S-functions and for answering certain questionsabout S-functions .The translation is determined by the following rules inwhich we denote the translation of an M-expression !.: by g*.2. Variables and function names that were represented bystrings of lower-case letters are translated to the correspondingstrings of the corresponding upper-case letters. Thus car*is CAR, and subst* is SUBST.3. A form f [el;...;en] is translated to (f*,ef,...,e;).Thus (cons[car[x];cdr[x]]>* is (CONS,(CAR,X),(CDR,X)).
- Page 1: Artificial Intelli~cnce GroupJ. McC
- Page 5: Contents1 . Introduction ..........
- Page 9 and 10: 2. Recursive Functions of Symbolic
- Page 12 and 13: expression was, defined, the meanin
- Page 14: Let f be an expression that stands
- Page 17 and 18: There is a twofold reason for depar
- Page 19 and 20: 2, eq - 4eq[x;y] is defined if and
- Page 21: 2. sub~t[x;~;z]This function gives
- Page 25 and 26: The S-functLon apply is defined byI
- Page 27 and 28: The list p - could be eliminated, a
- Page 29 and 30: 3. LISP PrimerThe features of LISP
- Page 31 and 32: The answer ( ((x A) B) (X A) ) will
- Page 33 and 34: one introducing it into the consequ
- Page 35 and 36: h,~~,pand)Y,SP5a. Rule4>: If j,++h,
- Page 37 and 38: to one of the 10 rules. The formula
- Page 39 and 40: (~111(LAMBDA( ~1 A2 A C) (COND ((NU
- Page 41 and 42: This causes the functions mentioned
- Page 43 and 44: 4. The LISP Programming SystemIn th
- Page 45 and 46: Example 3:The following example, on
- Page 47 and 48: In either case, if a machine-langua
- Page 49 and 50: Note that the argument x starts wit
- Page 51 and 52: sion whose first element may be LAM
- Page 53 and 54: 5 = (atomic function, arguments): C
- Page 55 and 56: - PROG is a special form described
- Page 57 and 58: When a list beginning with GO is en
- Page 59 and 60: Since the program feature will be u
- Page 61 and 62: and goes ahead after printing out(f
- Page 63 and 64: eturn[fn[a]In terms of the M-type n
- Page 65 and 66: ( , SXD, G0011,4),LD&,G0002)( ,C;LA
- Page 67 and 68: push-down(MAPLIST,BSS, 0)( ,SXD,GOO
- Page 69 and 70: Ls.( ,O,U( ,STO,G0015)( , LXD, $FRE
- Page 71 and 72: Running a LISP ProgramIn this secti
- Page 73 and 74:
SET :Note:FLX*:CRD*:FIN:This card w
- Page 75 and 76:
Sense switches used:SWITCH NUMBERUS
- Page 77 and 78:
The Flexowriter Sys tem (for M.1.T.
- Page 79 and 80:
indicates carriage returnindicates
- Page 81 and 82:
TEN-ModeThere are ten buffers of co
- Page 83 and 84:
ErrorsTyping errors may be erased b
- Page 85 and 86:
(from the tab type-in) will be proc
- Page 87 and 88:
answerTENCAR ((A@) 0- LINE NUMBER M
- Page 89 and 90:
6. List StructuresMuch of the follo
- Page 91 and 92:
y either the list structure of Fig.
- Page 93 and 94:
which is represented asFirst we con
- Page 95 and 96:
the location of the association lis
- Page 97 and 98:
and the decrement of the TXL instru
- Page 99 and 100:
the 2's (8's) complement of an octa
- Page 101 and 102:
25207 052567 05257025210 000000 000
- Page 103:
garbage collector does a linear swe
- Page 106 and 107:
The function collapse, is defined a
- Page 108 and 109:
THE TIME IS NOW 2/16 1139.7FUNCTION
- Page 110 and 111:
DEFINE( ( (RVRSE, (LAMBDA, (L ) JCO
- Page 113 and 114:
8. Error Indications Given by LISPB
- Page 115 and 116:
Errors due to computer inadequacies
- Page 117 and 118:
Errors during the operation of the
- Page 119 and 120:
9. Functions Available in LISPIn th
- Page 121 and 122:
s[x;y] : machine languageThe value
- Page 123 and 124:
eval[e;b] - : machine languageThe r
- Page 125 and 126:
Defining Functions:The argument of
- Page 127 and 128:
MORE]nconc[x;y]: machine languageTh
- Page 129 and 130:
evaluated functions. - map is used
- Page 131 and 132:
-ins t [x;y; z]: machine languageHe
- Page 133 and 134:
prog[prin2[d~rinl[~];The function p
- Page 135 and 136:
puncha[x] : machine languageThe fun
- Page 137 and 138:
9.2 Special Formsquote : machine la
- Page 139 and 140:
function[ f ] : machine language; s
- Page 141 and 142:
desc[cdr[x];cdr[y]-desc[x;y] : mach
- Page 143 and 144:
eturn[^]intv[x] : machine language;
- Page 145 and 146:
The program for compsrch has the pr
- Page 147 and 148:
NIL;T+The value of - cpl is the loc
- Page 149 and 150:
--- ~reaterlp; q] : machine languag
- Page 151 and 152:
matrixmultiply[x;y] : machine langu
- Page 153 and 154:
9.5 Alphabetic Index to FunctionsFu
- Page 155 and 156:
Function Page .mapcon .............
- Page 157 and 158:
GENERAL INDEXActive register, 96APP
- Page 159 and 160:
GENERAL INDEXFunctions, 3alphabetic
- Page 161 and 162:
GENERAL INDEXPropositionalcalculus;