cs150: Notes 6
Assignments Due
- (extended from 29 January) Before Monday, 5 February: Read GEB, Little Harmonic Labyrinth and GEB, Chapter 5
- Friday, 2 February (beginning of class): Problem Set 2. (Note: Problem
Set 2 will be accepted without penalty or any permission required until
the beginning of class on Monday, 5 February, as long as you promise to
still finish reading GEB Chapter 5 before Monday's class.)
Notes and Questions
Is it better to solve problems by thinking about what we need to do to
solve the problem (
procedures) or by thinking about what we
need to represent to solve the problem (
data)?
What does cons do?
What do car and cdr do?
What is the value of (car (cdr (cons 1 (cons 2 (cons 3 null)))))?
Why do we need the special list null?
Are there any data structures that cannot be built using just
cons?
How could we define cons, car and cdr if Scheme did
not have them as primitives?
A list is either (1) null or (2) a pair where the second
part of the pair is a list. To define procedures on lists, we need to
handle both cases: what do we do when the list is null and what
do we do when the list is a pair.
Define length a procedure that takes a list as its
operand and evaluates to the number of elements in that list.