Assignments Due
- As of now, you should have finished reading through the end of Section 5.4.
- Wednesday, 9 September:
GEB Reading
- Wednesday, 9 September: Expect to have a quiz testing that you are
keeping up with the assigned readings. If you have read and
superficially understood the Problem Set 1 Comments, the coursebook through Section 5.4 and the GEB
Reading, you should do well on the quiz.
- Monday, 14 September: Problem Set 2
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)?
A Pair packages two data values together. The built-in
procedures for manipulating Pairs include:
- cons: Value x Value → Pair — Outputs a Pair
containing the two input values in its cells.
- car: Pair → Value — Outputs the first cell of the
input Pair.
- cdr Pair → Value — Outputs the second cell of the
input Pair.
What does (car (cons x y)) evaluate to?
What does (cdr (cons x y)) evaluate to?
What is the value of (car (cdr (cons 1 (cons 2 (cons 3 null)))))?
Why do we need the special list null?
How could we define cons, car and cdr if Scheme did
not have them as primitives?
Are there any data structures that cannot be built using just cons?
A List is either (1) null or (2) a Pair whose second
cell is a List.
Why should we be especially optimistic that we can define a recursive
procedure to operate on a list?
Define list-trues as a procedure that takes a list as its
input and evaluates to the number of non-false values in that list.