University of Virginia, Department of Computer Science
CS200: Computer Science, Spring 2002

Notes: Monday 4 February 2002
Schedule

Defining For
(define for
  (lambda (count final body accum)
    (if (> count final)
        accum
        (for (+ count 1) final body (body accum count)))))
Notes
What 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.
Bob Paisley


CS 655 University of Virginia
Department of Computer Science
CS 200: Computer Science
David Evans
evans@cs.virginia.edu
Using these Materials