CSC151.02 2003F: Numeric Recursion, Continued Admin: * Final reminder for tonight's talk 7pm: Liberating Learning in the Sciences and Engineering: Lessons from Feminist and Radical Pedagogies * Grammar: "Pedagogy" approximately equals "Way of teaching" * No reading for tomorrow * Does anyone use the EBoards? How? * Grinnell Homecoming Parade, 5:30 p.m. Central Park Overview: * Review * Lab, Continued * Reflections Review: * What is the standard form of a recursive procedure? (define PROCEDURE (lambda (PARAMETER) (if BASETEST BASECASE (REBIGGIFY (PROCEDURE (SMALLIFIED PARAMETER)))))) (define PROCEDURE (lambda (PARAMETER) (if BASETEST BASECASE (EXPAND (PROCEDURE (SIMPLIFY PARAMETER)))))) * How do we specialize that form for numeric recursion? (define PROCEDURE (lambda (n) (if (zero? n) BASECASE (REBIGGIFY (PROCEDURE (- n 1)))))) * What are some particular examples? Factorial: * Procedure: factorial * Basecase: 1 * Expand: Multiply by n (define factorial (lambda (n) (if (zero? n) 1 (* n (factorial (- n 1)))))) Count-down: (define count-down (lambda (n) (if (zero? n) null (cons n (count-down (- n 1)))))) How *not* to write digit-of? (define digit-of? (lambda (dig num) (member? (string-ref (number->string dig) 0) (string->list (number->string num))))) (define member? (lambda (val lst) (and (not (null? lst)) (or (equal? val (car lst)) (member? val (cdr lst)))))) Conclusion: Sam Sux at Tux