The Scheme Programming Language, 4Th Edition
Total Page:16
File Type:pdf, Size:1020Kb
The Scheme Programming Language, 4th Edition The Scheme Programming Language, 4th Edition Table of Contents Table of Contents................................................................................................................................................1 Preface..................................................................................................................................................................5 Chapter 1. Introduction......................................................................................................................................9 Section 1.1. Scheme Syntax...................................................................................................................11 Section 1.2. Scheme Naming Conventions.....................................................................................12 Section 1.3. Typographical and Notational Conventions................................................................13 Chapter 2. Getting Started...............................................................................................................................15 Section 2.1. Interacting with Scheme....................................................................................................15 Section 2.2. Simple Expressions.....................................................................................................17 Section 2.3. Evaluating Scheme Expressions..................................................................................22 Section 2.4. Variables and Let Expressions....................................................................................23 Section 2.5. Lambda Expressions....................................................................................................25 Section 2.6. Top-Level Definitions.................................................................................................29 Section 2.7. Conditional Expressions..............................................................................................32 Section 2.8. Simple Recursion........................................................................................................37 Section 2.9. Assignment..................................................................................................................42 Chapter 3. Going Further................................................................................................................................51 Section 3.1. Syntactic Extension............................................................................................................51 Exercise 3.1.1..................................................................................................................................54 Section 3.2. More Recursion...........................................................................................................55 Section 3.3. Continuations...............................................................................................................62 Section 3.4. Continuation Passing Style..........................................................................................66 Section 3.5. Internal Definitions......................................................................................................68 Section 3.6. Libraries.......................................................................................................................72 Chapter 4. Procedures and Variable Bindings...............................................................................................75 Section 4.1. Variable References...........................................................................................................75 Section 4.2. Lambda........................................................................................................................75 Section 4.3. Case-Lambda...............................................................................................................76 Section 4.4. Local Binding..............................................................................................................78 Section 4.5. Multiple Values...........................................................................................................81 Section 4.6. Variable Definitions....................................................................................................81 Section 4.7. Assignment..................................................................................................................83 Chapter 5. Control Operations........................................................................................................................87 Section 5.1. Procedure Application.......................................................................................................87 Section 5.2. Sequencing..................................................................................................................88 Section 5.3. Conditionals.................................................................................................................88 Section 5.4. Recursion and Iteration...............................................................................................93 Section 5.5. Mapping and Folding..................................................................................................95 Section 5.6. Continuations...............................................................................................................99 Section 5.7. Delayed Evaluation...................................................................................................103 Section 5.8. Multiple Values.........................................................................................................105 Section 5.9. Eval............................................................................................................................110 Chapter 6. Operations on Objects.................................................................................................................113 Section 6.1. Constants and Quotation..................................................................................................113 Section 6.2. Generic Equivalence and Type Predicates................................................................115 i The Scheme Programming Language, 4th Edition Table of Contents Chapter 6. Operations on Objects Section 6.3. Lists and Pairs...........................................................................................................124 Section 6.4. Numbers....................................................................................................................133 Section 6.5. Fixnums.....................................................................................................................152 Section 6.6. Flonums.....................................................................................................................160 Section 6.7. Characters..................................................................................................................167 Section 6.8. Strings........................................................................................................................170 Section 6.9. Vectors.......................................................................................................................176 Section 6.10. Bytevectors..............................................................................................................179 Section 6.11. Symbols...................................................................................................................189 Section 6.12. Booleans..................................................................................................................191 Section 6.13. Hashtables...............................................................................................................191 Section 6.14. Enumerations...........................................................................................................196 Chapter 7. Input and Output.........................................................................................................................201 Section 7.1. Transcoders......................................................................................................................202 Section 7.2. Opening Files............................................................................................................203 Section 7.3. Standard Ports............................................................................................................205 Section 7.4. String and Bytevector Ports.......................................................................................206 Section 7.5. Opening Custom Ports...............................................................................................208 Section 7.6. Port Operations..........................................................................................................210 Section 7.7. Input Operations........................................................................................................212 Section 7.8. Output Operations.....................................................................................................216 Section 7.9. Convenience I/O........................................................................................................217 Section 7.10. Filesystem Operations.............................................................................................221