1.1 Lisp Lists In Lisp, a list looks like this: 'rosevioletdaisy This list is b a single apostrophe.. It just as well be written as follows, h looks more like the kind of list you are li
Trang 1Programming in Lisp
Trang 3Programming in Lisp
Edition
b Robert J.Chassell
Trang 4Permissionisgrantedto y,distributeand/ormodifythisdo tunder
thetermsoftheGNUFree Do tation Version1.1oranylater
versionpublishedb theFreeSoftwareFoundation; therebeingnoInvariant
withtheFront-Cover Textsbeing\A GNU Manual",and withthe
k-Cover Texts asin (a) below A y of the is inthe
entitled\GNU Free Do tation
(a) TheFSF's k-CoverText is: \You have freedom to yand modify
thisGNUManual,likeGNUsoftware Copiespublishedb theFreeSoftware
Trang 5Short Contents
xi
1 ListPro 1
2 Evaluation 23
3 How To Write F De nitions 29
4 A Few Buer{Related F 51
5 A Few More ComplexF 63
6 Narrowing and Widening 77
7 FundamentalF 81
8 Cuttingand Storing Text 89
9 How Listsare Implemented 113
10 Yanking Text k 117
11 Loops and 121
12 RegularExpression hes 149
13 Counting: Repetition and Regexps 167
14 Counting Words in adefun 181
15 Readying aGraph 203
16 Your File 213
17 Debugging 231
18 239
Appendix A The the-theF 241
Appendix B Handling the KillRing 243
Appendix C A Graphwith Labelled Axes 255
Appendix D GNU Free Do tation 279
Index 287
Trang 7Table of Contents
xi
OnReadingthisText xi
ForWhomThis isWritten xii
LispHistory xiii
ANote forNo xiii
ThankYou xiv
1 List Pro 1
1.1 LispLists 1
1.1.1 LispAtoms 1
1.1.2 inLists 3
1.1.3 GNU HelpsYouTypeLists 3
1.2 Run aProgram 4
1.3 Generate an ErrorMessage 4
1.4 SymbolNamesand F De nitions 6
1.5 The LispInterpreter 7
1.5.1 ByteCompiling 8
1.6 Evaluation 8
1.6.1 EvaluatingInnerLists 9
1.7 Variables 10
1.7.1 ErrorMessagefora SymbolWithoutaF 11 1.7.2 ErrorMessagefora SymbolWithout a Value 11
1.8 Arguments 12
1.8.1 Arguments' Data Types 13
1.8.2 AnArgument astheValueof a VariableorList 13 1.8.3 Variable Numberof Arguments 14
1.8.4 UsingtheWrong Type Ob asan Argument 14 1.8.5 Themessage F 16
1.9 Settingthe Value of aVariable 17
1.9.1 Usingset 17
1.9.2 Usingsetq 18
1.9.3 Counting 19
1.10 Summary 20
1.11 20
2 Evaluation 23
2.1 BuerNames 23
2.2 GettingBuers 25
2.3 hingBuers 26
2.4 BuerSize and theLo of Point 27
Trang 83 How To Write F De nitions 29
3.1 The defunSp Form 29
3.2 Install aF De nition 31
3.2.1 ChangeaF De nition 32
3.3 Make a F In e 33
3.3.1 An In e multiply-by-seven 34
3.4 Dierent Optionsfor 35
3.5 Install Code Permanently 36
3.6 let 36
3.6.1 TheParts ofa letExpression 37
3.6.2 SampleletExpression 38
3.6.3 UninitializedVariablesin aletStatement 39
3.7 The ifSp Form 39
3.7.1 Thetype-of-animalF inDetail 41
3.8 If{then{elseExpressions 42
3.9 Truthand Falsehoodin Lisp 43
3.10 44
3.10.1 Template fora Expression 45
3.11 Review 46
3.12 50
4 A Few Buer{Related F 51
4.1 FindingMoreInformation 51
4.2 A Simpli edbeginning-of-bufferDe nition 52
4.3 The De nitionofmark-whole-buffer 54
4.3.1 Bodyof mark-whole-buffer 55
4.4 The De nitionofappend-to-buffer 56
4.4.1 Theappend-to-bufferIn e Expression 57
4.4.2 TheBody ofappend-to-buffer 57
4.4.3 inappend-to-buffer 58
4.5 Review 60
4.6 61
Trang 95 A Few More Complex F 63
5.1 The De ... full programming language You use
Lispasyou wouldanyother programminglanguage
Perhapsyou want to understandprogramming; perhapsyou want to
ex-tend orperhapsyou want to b aprogrammer... Iamreferringto GNU Lispin
My thanksto all who helped mewith thisbook My esp thanksto
JimBlandy,NoahFriedman,JimKingdon,Roland FrankRitter,
Randy Smith, hard M Stallman, and MelissaWeisshaus... aprogrammer Thisintro
tion to Lispisdesigned to getyou started: to guide you in learning
thefundamentalsof programming, and more importantly ,to showyouhow
you h yourself to gofurther