CSC151.02 2003F, Class 12: Conditionals
Admin:
* Cool math talk tomorrow at 4:30. Snacks at 4:15.
* Friday is "Talk like a pirate day"
* No reading for Thursday!
* Rearrangement of syllabus
* Stuff due
Overview:
* Lab
* Refelection
* Style and conditionals
REFLECTION
* A useful way to do multiple comparisons
(<= 0 grade 100)
SOME STYLISTIC ISSUES
* Be careful about returning #t or #f from a conditional. Consider
(if SOME-TEST #t #f) => SOME-TEST
(if (<= 0 grade 100) #t #f) => (<= 0 grade 100)
(if SOME-TEST #f #t) => (not SOME-TEST)
(define in-range
(lambda (a b c)
(if (<= a b c)
#t
(if (>= a b c)
#t
#f))))
(define in-range
(lambda (a b c)
(if (<= a b c)
#t
(>= a b c))))
(define in-range
(lambda (a b c)
(or (<= a b c) (>= a b c))))
Whenever true or false is stated explicitly, you can probably get rid of it.
(if TEST1 #t TEST2) => (or TEST1 TEST2)
(if TEST1 #f TEST2) => (and TEST1 TEST2)