University of California, Berkeley
EECS Department - Computer Science Division

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

Review: Order of Evaluation and Advice from former students

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 90)
       'some-A
       (if (> score 80)
           'some-B
           (if (> score 70)
               'some-C
               'D-or-F))))
(cond (cond1 actions1 ... )
      (cond2 actions2 ... )
               ...
      (condN actionsN ... )
      (else  else-actions ... ))
(define (get-cs3-grade score)
   (cond ((> score 90) 'some-A)
         ((> score 80) 'some-B)
         ((> score 70) 'some-C)
         (else 'D-or-F)))

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...