← back to reading list

Scheme in 5 Minutes

Everything is an expression. Parentheses are function calls. That's it.

( + 3 4 ) operator operands = 7

Expressions

Every Scheme program is an expression. An expression in parentheses calls a function: the first element is the function, the rest are arguments. Nesting works the way you'd expect.

Scheme
Scheme
Scheme

Define

Use define to bind a name to a value or to define a function.

Scheme
Scheme

Lists

Lists are the core data structure. Quote a list with ' to prevent evaluation. car returns the first element, cdr returns the rest, cons adds an element to the front.

Scheme

Conditionals

if takes a test, a then-branch, and an else-branch. cond handles multiple branches.

Scheme
Scheme

Higher-order functions

Functions that take other functions as arguments. map applies a function to every element. filter keeps elements that pass a test.

Scheme

Lambda

lambda creates an anonymous function. You can pass it directly without naming it first.

Scheme

Let

let creates local bindings. Each binding is a name-value pair. The bindings are only visible inside the body.

Scheme
That's enough to read every page on this site.