;; distP : Posn Posn -> Number ;; computes distance between two points (define (distP p1 p2) (sqrt (+ (sqr (- (posn-x p1) (posn-x p2))) (sqr (- (posn-y p1) (posn-y p2)))))) ;; Examples/tests (= (distP (make-posn 0 0) (make-posn 5 12)) 13) (= (distP (make-posn 1 2) (make-posn 4 6)) 5) ;; To run the rest of this, uncomment the appropriate code and use teachpack draw.ss ;; create a canvas ;(start 300 300) ;; demonstrates a way that Posns can be generated interactively ;(wait-for-mouse-click) ;; demonstrates how such Posns can be generated and passed to a useful function ;(distP (wait-for-mouse-click) (wait-for-mouse-click))