CSC151.02 2003F, Class 16: More Recursion Admin: * Questions on hw2? * Do we need to write the six P's? Yes. Follow the lab-writeup format. * Can we copy the six P's that Sam wrote already? Yes, provided you cite 'em. * Questions on the exam? * Should we log our time? Yes. * Questions on the lab? * Reflect Thursday * Extra credit for attending Thursday's convo * Yes, you get extra credit even if your mean, cruel, and ultimately helpful tutorial professor requires you to go (or if your nice Physics professor requires you to go or if your mother requires you to go or Reese threatens to bop you with a volleyball if you don't go or if you have to serve refreshments during the convocation). Overview: * Which sum did you prefer? Why? * Watching procedures * Lab 1 * Lab 2 (if there's time; continue Thursday) Filtering Lists Consider the following helpful procedure (define filter-out-negatives (lambda (ls) (if (null? ls) null (if (negative? (car ls)) (filter-out-negatives (cdr ls)) (cons (car ls) (filter-out-negatives (cdr ls))))))) In what order does the result appear? Is it perhaps reversed? (filter-out-negatives (list 1 -2 3)) => (cons 1 (filter-out-negatives (list -2 3))) => (cons 1 (filter-out-negatives (list 3))) => (cons 1 (cons 3 (filter-out-negatives (list)))) => (cons 1 (cons 3 null)) => (cons 1 (list 3)) => (list 1 3) (1 3) Note: It's often worth the time to try to execute a procedure "by hand". Five minutes of hand-execution is worth hours of understanding.