University of Virginia Computer Science
CS150: Computer Science, Fall 2005

(none)
2 September 2005

CS150 Notes 5 (2 September 2005)

Assignments Due

Null/Nil Confusion

In SICP, they use nil. In MzScheme (DrScheme's language), they use null. The Revised5 Report on the Algorithmic Language Scheme mentions nil but uses the empty list (denoted by '()) instead. As the footnote on page 101 explains, the exact meaning and name for the empty list is cause for lots of dispute and confusion. We will use null in class to be consistent with MzScheme, and reserve nil for reporting soccer scores.

Notes and Questions
If two procedures define the same function (that is, they both produce exactly the same results for all inputs) how could one definition be better than the other?







If instead of using the definitions we used in class, we defined cons as:

(define (cons a b)
 (lambda (w) (if (w) b a)))
How could we define car and cdr to have the standard meaning?





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.













"); print ( $res[$first] ) ; print (""); ?>
CS 150: Computer Science
University of Virginia
evans@virginia.edu
Using these Materials