I'm trying to write a procedure that returns the longest distance between the farthest two points in a list. My list is
((2 . 4) (3 . 6) (5 . 12) (-4 . 3) (8.4 . 9) (0 . -1))
And i've already written a distance procedure and one that returns the maximum distance between two points:
(define (max-distance p pt-list)
(if (null? pt-list)
0
(max (distance p (car pt-list))
(max-distance p (cdr pt-list)))))
Now, I just need to write something that only returns the largest value obtained by taking two of those points. What I have so far is
(define (max-range pt-list)
(if (null? pt-list)
0
(max (max-distance (car pt-list) (pt-list))
(max-range (cdr pt-list)))))
However, when i run the test case (display+ (max-range my-pt-list))
i get the error: The object ((0 . -1)) is not applicable, which leads me to believe that it is working up until it reaches the last point.