CS200: Computer Science, Spring 2002
Notes: Monday 4 February 2002
- 6 February: Read SICP, 2.1 and 2.2 (through page 127). You don't need to read the example section 2.2.4, but probably don't want to miss the footnote on page 127 about William Barton Rogers, MIT's founder, who left UVa after too many students were rioting outside his pavillion.
- 13 February: Problem Set 3
- Before 18 March: GEB all of Part I
Defining For(define for (lambda (count final body accum) (if (> count final) accum (for (+ count 1) final body (body accum count))))) NotesWhat does cons do?
What do car and cdr do?
How could we define cons, car and cdr if Scheme did not have them as primitives?
A quintuple is a pair where ...
A list is either ...
(define (sum n) (insertl + (intsto n))) ;;; Evaluates to the list (1 2 3 n) if n >= 1, ;;; null if n = 0. (define (intsto n) (if (= n 0) null (append (intsto (- n 1)) (list n)))) ;;; Inserts function f between the elements of the list. ;;; e.g., (insertl + (list 1 2 3 4)) ==> (+ 1 (+ 2 (+ 3 (+ 4 (+))))) (define (insertl f lst) ;;; Left for you to do for next class )
If you're in the penalty area and don't know what to do with the ball, put it in the net and we'll discuss the options later.
University of Virginia
Department of Computer Science
CS 200: Computer Science
Using these Materials