Teach Yourself Scheme in Fixnum Days

How to Design Programs: An Introduction to Programming and Computing

Info icon This preview shows pages 1–5. Sign up to view the full content.

Teach Yourself Scheme in Fixnum Days c Dorai Sitaram, 1998–2004 All Rights Reserved ds26 at gte.com Contents Preface, 3 1 Enter Scheme, 4 2 Data types, 6 2.1 Simple data types, 7 2.1.1 Booleans, 7 2.1.2 Numbers, 7 2.1.3 Characters, 8 2.1.4 Symbols, 9 2.2 Compound data types, 10 2.2.1 Strings, 10 2.2.2 Vectors, 11 2.2.3 Dotted pairs and lists, 11 2.2.4 Conversions between data types, 13 2.3 Other data types, 14 2.4 S-expressions, 14 3 Forms, 14 3.1 Procedures, 15 3.1.1 Procedure parameters, 16 3.1.2 Variable number of arguments, 16 3.2 apply , 16 3.3 Sequencing, 16 4 Conditionals, 17 4.1 when and unless , 18 4.2 cond , 19 4.3 case , 19 4.4 and and or , 19 5 Lexical variables, 20 5.1 let and let* , 22 5.2 fluid-let , 23 6 Recursion, 24 6.1 letrec , 25 6.2 Named let , 26 6.3 Iteration, 26 6.4 Mapping a procedure across a list, 27 7 I/O, 27 7.1 Reading, 28 7.2 Writing, 28 7.3 File ports, 28 7.3.1 Automatic opening and closing of file ports, 29 7.4 String ports, 29 7.5 Loading files, 30 1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

8 Macros, 30 8.1 Specifying the expansion as a template, 32 8.2 Avoiding variable capture inside macros, 33 8.3 fluid-let , 34 9 Structures, 35 9.1 Default initializations, 36 9.2 defstruct defined, 37 10 Alists and tables, 38 11 System interface, 40 11.1 Checking for and deleting files, 41 11.2 Calling operating-system commands, 41 11.3 Environment variables, 41 12 Objects and classes, 42 12.1 A simple object system, 43 12.2 Classes are instances too, 47 12.3 Multiple inheritance, 48 13 Jumps, 49 13.1 call-with-current-continuation , 50 13.2 Escaping continuations, 51 13.3 Tree matching, 52 13.4 Coroutines, 53 13.4.1 Tree-matching with coroutines, 54 14 Nondeterminism, 55 14.1 Description of amb , 56 14.2 Implementing amb in Scheme, 57 14.3 Using amb in Scheme, 58 14.4 Logic puzzles, 59 14.4.1 The Kalotan puzzle, 60 14.4.2 Map coloring, 61 15 Engines, 63 15.1 The clock, 64 15.2 Flat engines, 65 15.3 Nestable engines, 66 16 Shell scripts, 68 16.1 Hello, World!, again, 69 16.2 Scripts with arguments, 70 16.3 Example, 71 17 CGI scripts, 72 17.1 Example: Displaying environment variables, 73 17.2 Example: Displaying selected environment variable, 75 17.3 CGI script utilities, 77 17.4 A calculator via CGI, 80 A Scheme dialects, 82 A.1 Invocation and init files, 83 A.2 Shell scripts, 84 A.3 define-macro , 84 A.4 load-relative , 85 B DOS batch files in Scheme, 86 2
Image of page 2
C Numerical techniques, 88 C.1 Simpson’s rule, 89 C.2 Adaptive interval sizes, 91 C.3 Improper integrals, 93 D A clock for infinity, 95 E References, 98 F Index, 100 3
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Preface This is an introduction to the Scheme programming language. It is intended as a quick-start guide, something a novice can use to get a non-trivial working knowledge of the language, before moving on to more comprehensive and in-depth texts. The text describes an approach to writing a crisp and utilitarian Scheme. Al- though we will not cover Scheme from abs to zero? , we will not shy away from those aspects of the language that are difficult, messy, nonstandard, or unusual, but never- theless useful and usable. Such aspects include call-with-current-continuation , system interface, and dialect diversity. Our discussions will be informed by our fo- cus on problem-solving, not by a quest for metalinguistic insight. I have therefore left out many of the staples of traditional Scheme tutorials. There will be no in-
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '07
  • Fisler
  • Scheme Programming Language

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern