The Scheme Programming Language


Click here to start

Table of Contents

The Scheme Programming Language

Scheme philosophy


C vs. Scheme expressions

Prefix vs. infix

Nested expressions 1

Nested expressions 2

Nested expressions 3

Nested expressions 4

Nested expressions 5

Evaluating arguments


More types

What’s in a symbol?

Some “literals” evaluate to themselves

Symbols evaluate by variable lookup

define special form

Lists evaluate by procedure application*

Special forms

List evaluation

Creating symbol value

Suppressing evaluation

quote special form


Forcing evaluation with eval

The Lambda Calculus

Creating procedures with the lambda special form

A moment for syntax

Naming a procedure

Shorthand for procedure definition

Procedures vs. variables

Conditionals: if special form

C vs. Scheme

C vs. Scheme

eq? procedure tests for identity equality


Linear recursive process

Lists are made of cons cells

cons cells and the cons procedure

List syntax shorthand

Beware the arrow: Another look at lists

car, cdr, and friends

Nested lists

Do not try this at home

our-list-ref procedure

our-list-ref trace Linear iterative process

Contrast the inductive steps


our-list-ref tail recursion

Re-binding is NOT assignment

Iterative version of factorial

Iterative factorial trace

Nested procedure defines

Factoring out common sub-expressions

let special form

Scope is visibility

let bindings happen in parallel

Bad let bindings

let* special form

More about conditionals: cond special form

cond example

Short-circuiting and, or special forms

Boolean values & and, or

Procedures are first-class values

map, a higher-order function

Filter procedure

Typechecking predicates

Procedure factories

Building procedures

Dr. Scheme Graphics

lambdas and closures

lambdas and their environments

Free variables and Lexical Scoping

Dynamic Scoping

Lexical vs. Dynamic Scope

Lexical scope and variable hiding

When the arguments don’t fit

A more direct approach: the apply procedure

Procedure arity

Rest arguments

Controlling evaluation inside of lists

quasiquote and unquote

Forcing and suppressing evaluation are fundamental


eq?, eqv?, equal?

More eq?, eqv?, equal?

Objects/values in the Scheme Heap

Do not use eq? for numbers

Making new lists

Sharing of list structure

append must duplicate the list

List surgery

set-cdr! and set-car!


set! procedure

Other side-effects

Sequencing and the begin special form

Author: Greg J. Badros


Home Page: