CSC151, Class 23: Lab: Local Bindings Overview: * Lab * Reflection Notes: * Any final questions on the exam? * Writing a variant of round. "I want round to always round up and not do the weirdo "round towards even" thing that it does." 2.5 => 3 3.5 => 4 4.5 => 5 * Questions on let? ---------------------------------------- Exam questions: Q For number of quadratic roots, can I just find the two roots and see if they're both real and equal? A No. Be smarter. ---------------------------------------- Reflection: * For exercise 2: (let .... (+ alpha beta gamma delta epsilon)) * Why did I have you do exercise 2? So that you'll never forget the format of lets (let ((NAME EXP) ...) BODY) * Why is let like a liberal arts college? * Because it lets you define your own little world which need bear no resemblance to the outside world. Here's a very silly procedure (define silly (lambda (val) (display val) (newline) val)) (define multiply-by-two-a (lambda (lst) (let ((multiplier (silly 2))) (if (null? lst) null (cons (* (car lst) multiplier) (multiply-by-two-a (cdr lst))))))) (define multiply-by-two-b (let ((multiplier (silly 2))) (lambda (lst) (if (null? lst) null (cons (* (car lst) multiplier) (multiply-by-two-b (cdr lst))))))) How do I generate really long lists? (vector->list (make-vector 1000 5))