Introductory R7RS Scheme
Layer 1: enough Scheme to solve basic exercises.
This course layer teaches the core ideas needed before attempting introductory Scheme exercise sets: expressions, definitions, conditionals, symbols, lists, recursion, growth, tail calls, higher-order procedures, data abstraction, and hierarchical data.
Available Lessons
- Lesson 0: how to read Scheme before writing itParentheses, prefix calls, identifiers, literals, glossary terms, highlighting conventions, and course expectations.
- Lesson 1: defining procedures and checking resultsFunction composition, formal and actual arguments, conditionals, simple recursion, pairs, proper lists, and executable checks.
- Lesson 2: higher-order proceduresProcedures as values,
lambda, filtering with predicates, procedure-returning procedures, andlet. - Lesson 3: recursion, iteration, and growthOrder of growth, recursive list traversal, tail position, accumulators, insertion sort, and repeated work.
- Lesson 4: data abstraction and pair diagramsConstructors, selectors, abstraction barriers, pairs, proper lists, nested structure, and checked diagrams.
- Lesson 5: hierarchical data and tree shapesTree vocabulary, n-way and binary trees, tree ADTs, nested-list trees, and tree mapping.
- Browser evaluator compatibility noteBiwaScheme version pinning, R7RS differences, exactness caveats, and plain-text course output.
Scope
This is a concrete starting layer, not a complete course. It is designed to prepare readers for early exercises from classic Scheme introductions while using explicit R7RS imports and tested examples.
What This Layer Must Cover
- Expressions and valuesNumbers, booleans, symbols, strings, procedure calls, and nested expressions.
- DefinitionsNaming values and procedures so examples can grow beyond one-line REPL experiments.
- Conditionals and predicatesChoosing among cases with
if,cond, predicates, and boolean combinations. - Pairs and listsUsing
cons,car,cdr, quotation, and structural decomposition. - Data abstractionUsing constructors, selectors, and diagrams to separate meaning from representation.
- Hierarchical dataRepresenting roots, nodes, leaves, subtrees, and nested structures.
- RecursionWriting procedures that follow the shape of lists and trees.
- Growth and tail callsEstimating one-pass and nested work; using proper tail recursion for loop-shaped procedures.
- Higher-order proceduresPassing predicates and transformers as values; reading simple uses of
mapand similar procedures. - R7RS program shapeEvery file starts with imports such as
(scheme base), rather than relying on an unspecified REPL environment.
First Tested Example
The current checked example sources are published at /examples/r7rs/intro/lesson-01/, /examples/r7rs/intro/lesson-02/, /examples/r7rs/intro/lesson-03/, /examples/r7rs/intro/lesson-04/, and /examples/r7rs/intro/lesson-05/. They check definitions, conditionals, simple recursion, list operations, higher-order procedures, local binding, tail recursion, growth examples, constructors, selectors, data abstraction, and tree mapping.
(import (scheme base)
(scheme write)
(scheme process-context))
(define (square-number n)
(* n n))
(define (rectangle-area width height)
(* width height))
(define (factorial n)
(cond
((or (not (integer? n)) (< n 0))
(error "factorial: expected a nonnegative integer" n))
((<= n 1) 1)
(else (* n (factorial (- n 1))))))
The full checked files add assertions around these definitions. The CHICKEN command currently used for local verification is:
scripts/test_examples_chicken.sh
Exercise Readiness
After this layer, a reader should be ready for early exercises involving arithmetic expressions, predicates, list selectors, symbolic data, simple recursion over lists, tail-recursive loops, growth estimates, and small procedure definitions. More advanced exercise sets require later layers on trees, abstraction, local binding, mutation, macros, and interpreters.
Related References
- R7RS smallThe standard used for imports and portable baseline behavior.
- Teach Yourself Scheme in Fixnum DaysA compact older tutorial; examples need R7RS review before reuse.
- An Introduction to Scheme and its ImplementationUseful older topic coverage for basic Scheme and implementation ideas.
- r5.rsClassic Scheme, SICP-era material, Simply Scheme, early reports, and historical resources.