Scheme from the ground up
A language of lists, where the code is the data
- Beginner
- 12 chapters
- 218 min read
Learn Scheme by writing it: brackets and prefix notation, names and values, decisions, the list that everything is built from, functions you define yourself, recursion in place of loops, loops that carry an accumulator, map and filter, symbols and little tables, text, vectors and private state, ending with a small library that uses all of it.
What You'll Learn
- Read and write prefix notation, and print with print and display
- Name values with define and let, and ask a value what it is
- Choose between branches with if and cond, using the truth rule
- Build and take apart lists with cons, car, cdr, append and reverse
- Define your own functions with lambda and the bracketed define
- Solve problems by recursion, with a stopping case that ends the walk
- Write a named let loop and carry an accumulator through it
- Replace hand-written walks with map, filter, apply and for-each
- Use symbols as keys, and tell eq? apart from equal?
- Cut, join and convert text, including the number conversions
- Update a vector in place, and keep state private inside a function
- Compose a small library from records, lookups and formatted output
Prerequisites
- No programming experience needed — this course starts at the first bracket
- Any other language you know will make the early chapters quick
Course Content
- 01Your first SchemeNot started
What Scheme is, why the operation comes first, and the two ways to write something out: print and display.
- 02Names for valuesNot started
Naming a value with define, local names with let, asking a value what it is, and the one way a name can change.
- 03Deciding with if and condNot started
Two truth values, the rule that only one of them is false, and the two ways to choose between branches: if and cond.
- 04Lists, the big ideaNot started
The one structure Scheme is built from: how a list is put together with cons, how to take it apart with car and cdr, and how to walk it.
- 05Making your own wordsNot started
Lambda, the two ways to name a function, local helpers, and the idea that a function is a value you can hand to another function.
- 06Recursion instead of loopsNot started
A function that calls itself, the stopping case that ends it, and the same three-line shape for every walk down a list.
- 07Loops you can readNot started
The named let, which is a loop made of a function, and the accumulator pattern for building a list in order.
- 08Map, filter and friendsNot started
The built-in helpers that replace most hand-written walks: map to change every value, filter to keep some, apply to spread a list into a call.
- 09Symbols and little tablesNot started
Names used as plain data, the difference between comparing identity and comparing contents, and tables built from pairs.
- 10Text, taken apartNot started
Strings from the inside: cutting them up, joining them, changing their case, and the two conversions that let text join in the arithmetic.
- 11Change, and vectorsNot started
The two kinds of change in Scheme: repointing a name with set!, and updating a slot in a vector — plus the closure that keeps state to itself.
- 12A small library, end to endNot started
An address book built from everything in the course: records, a table lookup, a recursive walk, text formatting, and one controlled escape.
