University of California, Berkeley
EECS Department - Computer Science Division

CS3 Once-a-Week (OaW) Lecture 3
(Order of Evaluation, Booleans, Conditionals) Domain & Range, Abstraction
http://inst.eecs.berkeley.edu/~cs3/

Review: Order of Evaluation

Review: True and False

Combining predicates with and, not and or

A B (and A B) (or A B) (not B)
#f #f #f #f #t
#f #t #f #t #f
#t #f #f #t #t
#t #t #t #t #f

If : How we make decisions...

(+ 365 (if (leap-year? year) 1 0)) ==> 366

cond: Writing conditionals

(define (get-cs3-grade score)
   (if (> score 185)
       'A+
       (if (> score 165)
           'A
           (if (> score 155)
               'A-
               'Did-not-get-an-A))))
(cond (cond1 actions1 ... )
      (cond2 actions2 ... )
               ...
      (condN actionsN ... )
      (else  else-actions ... ))
(define (get-cs3-grade score)
 		  (cond ((> score 185) 'A+)
 		        ((> score 165) 'A )
 		        ((> score 155) 'A-)
 		        (else 'Did-not-get-an-A)))

Common Confusions

Announcements

Domain and Range

Abstraction

General Idea

Functional Abstraction

Data Abstraction

Data Abstraction Example ... let's make a school!

(define (make-school name mascot)
   (word name mascot))

In Lab this week you'll see...

In Life this week you'll see...