CSC151.01 2006S, Class 09: Boolean Values and Predicates Admin: * Absent: LaRue, McCardle, McFarlin, Zamora * Not a good day! * Warning! Sam makes phone calls. * Reading: Conditionals * Due: HW4. * Available generally in the near future * Assigned: HW5. * EC: Tuesday Extra: Significance from Insignificance (two recent alums) Overview: * The Components of an Algorithm, Revisited. * Questions on the Reading? * Lab. /The Components of an Algorithm, Revisited/ * Basic types and operations: * Numbers * Strings * Symbols * Lists * Boolean - and, or, not * Naming * define * Sequencing * In definitions window * Implicit in nested expressions. * Conditionals * Can tell if things are truish or false * And can make different decisions, using clever versions of and and or * NOT YET (note that it's the title of the reading for Monday) * Loops * NOT YET * Subroutines * Procedures. /Questions on the Reading/ * If there's only (and), the value is #t * If there's only (or), the value is #f * Is there a logic to that result? Yes. * Will I tell you the logic? No. The lab brings up the same question and, after you've thought about it, the answer is at the end. /Notes on the Lab/ * Q: Differences between 'eq?' and 'eqv?' * A: There are few such diffences. The only one I know of is "large numbers" > (eq? (expt 3 100) (expt 3 100)) #f > (eqv? (expt 3 100) (expt 3 100)) #t * Q: So why do you bring up eq? in this reading and lab? * A: For the sake of completeness * A: Just use eqv? or equal? * Q: What are some ways to express "grade is between 0 and 100, inclusive?" (define valid0 (lambda (grade) (and (<= 0 grade) (<= grade 100)))) (define valid1 (lambda (grade) (and (<= 0 grade) (>= 100 grade)))) (define valid2 (lambda (grade) (or (= grade 0) (= grade 100) (and (> grade 0) (< grade 100))))) (define valid3 (lambda (grade) (<= 0 grade 100))) (define valid4 (lambda (grade) (and (number? grade) (<= 0 grade 100))))