[an error occurred while processing this directive]

## cs150: Notes 9

#### find-closest

```(define (find-closest-number goal numbers)
(if (= 1 (length numbers))
(car numbers)
(if (< (abs (- goal (car numbers)))
(abs (- goal
(find-closest goal (cdr numbers)))))
(car numbers)
(find-closest goal (cdr numbers)))))

(define (find-closest goal lst closeness)
(if (= 1 (length lst))
(car lst)
(if (< (closeness goal (car lst))
(closeness goal
(find-closest goal (cdr lst) closeness)))
(car lst)
(find-closest goal (cdr lst) closeness))))

(define (pick-closest closeness goal num1 num2)
(if (< (closeness goal num1)
(closeness goal num2))
num1
num2))

(define (find-closest goal lst closeness)
(if (= 1 (length lst))
(car lst)
(pick-closest closeness goal (car lst)
(find-closest goal (cdr lst) closeness))))

```
Languages

How can we compare notations for describing languages?

What is the difference between RTN and BNF?

Music and Recursion Song ::= Verse VBBD VBBD Better Coda
VBBD ::= Verse Bridge Bridge Dadada (ends on C)
Coda ::= F Eb Bb F Coda
Note: the Coda has no base case, and should continue forever (time permitting).
Challenge Problem
Define a Scheme procedure that can produce the INT and Gplot graphs from GEB Chapter 5. Hint: you may need to think about curves differently from PS3. (A solution is worth two gold stars.)

Links

Hofstadter's Law: It always takes longer than you expect,
even when you take Hofstadter's Law into account.