distance



Write a function that determines the distance between two points The coordinates of the point are represented as a list (x y)


Solution

(define (distance p1 p2)
  (let
      ((a (- (car p1) (car p2)))
       (b (- (car (cdr p1)) (car (cdr p2)))))
    (sqrt
     (+ (* a a) (* b b)))))