Menu

- Chapter 1 Distilled
- Introduction
- 1.1 - The Elements Of Programming
- Expressions
- Naming and the Environment
- Evaluating Combinations
- Defining New Functions
- The Substitution Model
- Exercises
- Predicates
- Conditional Expressions
- Example: Newtonâ€™s Method
- Functions as Black-Box Abstractions
- 1.2 - Procedures and the Processes They Generate
- Linear Recursion and Iteration
- Tree Recursion
- Orders of Growth
- Exponentiation
- Example: Testing For Primality
- 1.3 Higher Order Functions
- Project - Blackjack

- Chapter 2 Distilled
- Introduction
- Data Abstraction
- Everything From Nothing
- Abstractions In Clojure
- Clojure's Data Structures
- Data Abstraction, Revisited
- Escher
- Project - Escher
- Symbolic Data
- Representing Sets
- Huffman Encoding Trees
- Zippers

One of our goals in this chapter is to isolate issues about thinking procedurally.

In evaluating combinations, *the interpreter is itself following a
procedure*

- Evaluate the subexpressions of the combination
- Apply the function that is the value of the leftmost subexpression (the operator) to the arguments that are the values of the other subexpressions (the operands).

Note that the first step says that in order to accomplish the
evaluation process for a combination we must first perform the
evaluation process on each element of the combination. Thus, the
evaluation rule is *recursive* (it needs to invoke itself)

Have a look at this expression :

```
(* (+ 2 (* 4 6))
(+ 3 5 7))
```

Two things are being multiplied by `*`

`(+ 2 (* 4 6))`

and

`(+ 3 5 7)`

We have to evaluate both of them, in order to evaluate the first we
need to evaluate `2`

and `(* 4 6)`

, which makes us have to recur
again. You can think of the s-expressions as a tree with partial
evaluations percolating upwards

Note also that we are asked to evaluate primitive expressions, and:

- the values of numerals are the numbers that they name
- the values of built-in operators are the machine instruction sequences that carry out the corresponding operations
- the values of other names are the objects associated with those names in the environment.

Notice that the evaluation rule given above does not handle
definitions. For instance, evaluating `(def x 3)`

does not apply
define to two arguments, one of which is the value of the symbol x and
the other of which is 3

We will see more special forms soon, each has its own evaluation
rule. The various kinds of expressions (each with its associated
evaluation rule) constitute the *syntax* of the programming language.

In comparison with most other programming languages, Lisps have a very simple syntax.