# Class 06: An Introduction to Scheme

Back to Cascading Style Sheets. On to Symbols and Lists.

Held: Friday, 5 September 2003

Summary: Today we begin our investigations of the core language for the course, Scheme. Scheme is a simple functional language with many imperative features and very little syntax.

Related Pages:

Assignments

Notes:

• Are there any questions on Homework 1?
• Lots of arts events this weekend, including the Grinnell Festival of the Arts and the opening of Roots of Renewal. Extra credit for attending Roots of Renewal this weekend (provided it's open).
• Advance warning: September 16 is Talk Like a Pirate Day. At least one member of this class has asked that we follow the guidelines. Let me know via email if you object.

Overview:

## Scheme Basics

• Scheme is generally used in an interactive environment: You type syntactically-valid expressions and Scheme returns their values.
• Later this semester, we'll see how to use Scheme in different environments.
• Scheme's syntax is fairly simple: Since almost everything in Scheme involves the application of a function to some arguments, you write:
• an open parenthesis;
• the name of the procedure;
• a space;
• the parameters to the procedure (separated by spaces); and
• a close parenthesis.
• For example,
```(+ 2 3 4)
(sqrt 4)
(expt 2 3)
```
• If you remember this basic syntactic structure, you'll rarely get syntactic errors from Scheme.

## Some Procedures You Should Know

• `+`: Sum its parameters.
• `*`: Compute the product of its parameters.
• `-`: Subtract the second parameter from the first.
• `(sqrt val)`: Compute the square root of val.
• `(expt v p)`: Compute vp.
• `(absabs v)`: Compute the absolute value of v.

## A Short History of Scheme

• Scheme is a variant of Lisp (the List processing language).
• Lisp is one of the oldest high-level programming languages in active use
• It's from about the time of the invention of Cobol and only a few years after the invention of Fortran.
• John McCarthy (of MIT and then Stanford) designed Lisp to provide a language for programming in artificial intelligence.
• At the time, many people believed that intelligence was grounded in symbolic processing.
• Lisp added many things to languages of the day:
• Symbolic values
• Dynamic lists as built-in data structures
• Automatic memory managment for those built-in data structures
• Functions as values (we'll return to this in a few weeks)
• In later reflection, McCarthy indicated that some of these things were just luck. For example, the `lambda` that you'll learn about soon was just a "hmmm ... that sounds interesting, I'll put it in" fluke.
• Scheme was designed in the early 1980's (or maybe late 1970's) as a variant of Lisp more appropriate for teaching computer science (and doing many other things; it's more elegant).
• Scheme has a slightly clearer semantics than Lisp (and a formal semantics, which is important).
• But, at least for 151, you're doing Lisp-like programming.

## Labs

• You'll need to figure out DrScheme before you can write any Scheme, so start with The DrScheme Lab.
• After a little while of playing with DrScheme, you should be ready for the Beginning Scheme lab.
• I hope to spend the last few minutes of class giving you a chance to reflect on your first experiences with Scheme.

## History

Thursday, 28 August 2003 [Samuel A. Rebelsky]

• Created automatically.

Back to Cascading Style Sheets. On to Symbols and Lists.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue Dec 9 13:59:32 2003.
The source to the document was last modified on Mon Sep 1 13:30:51 2003.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2003F/Outlines/outline.06.html`.

You may wish to validate this document's HTML ; ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu