I\'m currently trying to write a function from a list of points that returns the distance from a point p to a point in my point list that is farthest away from p. My list of poi
Compute the distance to the car of points. Either that distance is the maximum or the maximum from the cdr of points is. Result is a simple recursive algorithm traversing the list of points.
(define (max-distance-p p points)
(if (null? points)
0
(max (distance p (car points))
(max-distance-p p (cdr points)))))
The 0 is returned if you pass in points as an empty list; that might be a bit questionable. If so:
(define (max-distance-p p points)
(assert (not (null? points)))
(if (null? (cdr points))
(distance p (car points))
(max (distance p (car points))
(max-distance-p p (cdr points)))))