; find the minimum difference
(define (f xs ys)
(let ((d (- (car xs) (car ys))))
(let loop ((xs xs) (ys ys) (diff (abs d)))
(cond ((or (null? xs) (null? ys)) diff)
((< (car xs) (car ys))
(let ((d (- (car ys) (car xs))))
(loop (cdr xs) ys (min d diff))))
(else (let ((d (- (car xs) (car ys))))
(loop xs (cdr ys) (min d diff))))))))
(display (f '(19 22 24) '(37 38 49 88)))