CSC151, Class 36: Algorithmic Art Overview: * Discussion of exam 2 * More on circles * About images * Algorithmically generating and modifying images * Lab Notes: * Admitted students may be visiting. * How should we structure today's class? * Questions and answers on exam 2. ---------------------------------------- Question 2: in-tree? DONT' WRITE DOCUMENTATION Remember that a tree is either (1) a non-pair value or (2) a pair of two trees. That recursive data structure definition should help you write procedures that do things with trees. ---------------------------------------- Question 3: list-of-integers->string DON'T WRITE DOCUMENTATION Number of approaches. One good one: Don't worry about the parens. Then worry about the parens. ---------------------------------------- Question 4: Ugly code YES, YOU HAVE TO DOCUMENT How should you approach (define r (lambda (l p?) (letrec ((c (lambda (p v) (let ((x (if (p? v) 1 0))) (cons (+ (car p) x) (+ (cdr p) (- 1 x)))))) (r (lambda (q m) (if (null? m) (/ (car q) (cdr q)) (r (c q (car m)) (cdr m)))))) (r (cons 0 0) l)))) * Determine the types of the parameters. * Try some sample calls to see if they reveal clues. * Figure out more types. * Gradually expand the parts you can tell about. ----------------------------------------