Errata for Picturing Programs -- 14

© Stephen Bloch 2011

Feb. 4, 2011

pp. 258-259: Formatting errors that caused overprinting. It should read:

Then we need to add those two squares:

(define (distance-to-top-left the-point)
  ; the-point              a posn
  ; (posn-x the-point)     a number (x)
  ; (posn-y the-point)     a number (y)
  ; (* (posn-x the-point) (posn-x the-point))    a number (x2)
  ; (* (posn-y the-point) (posn-y the-point))    a number (y2)
  ; (+ (* (posn-x the-point) (posn-x the-point))
  ;    (* (posn-y the-point) (posn-y the-point))) a number (x2+y2)
  ...)

and finally square-root that, using sqrt:

(define (distance-to-top-left the-point)
  ; the-point              a posn
  ; (posn-x the-point)     a number (x)
  ; (posn-y the-point)     a number (y)
  ; (* (posn-x the-point) (posn-x the-point))    a number (x2)
  ; (* (posn-y the-point) (posn-y the-point))    a number (y2)
  ; (+ (* (posn-x the-point) (posn-x the-point))
  ;    (* (posn-y the-point) (posn-y the-point))) a number (x2+y2)
  (sqrt (+ (* (posn-x the-point) (posn-x the-point))
           (* (posn-y the-point) (posn-y the-point))))
  )