;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname 28.2.1) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
; Worked exercise 28.2.1

; any-compares? : (number number -> boolean) number list-of-numbers -> boolean
(check-expect (any-compares? >= 5 (list 2 5 1)) true)
(check-expect (any-compares? > 5 (list 2 5 1)) false)
(check-expect (any-compares? = 5 (list 2 5 1)) true)
(check-expect (any-compares? = 5 (list 2 6 1)) false)
(check-expect (any-compares? < 5 (list 2 6 1)) true)
(check-expect (any-compares? < 5 (list 7 6 8)) false)

(define (any-compares? compare? num nums)
  ; compare?       number number -> boolean
  ; num            number
  ; nums           list of numbers
  (cond [(empty? nums) false]
        [(cons? nums)
         (or (compare? (first nums) num)
             (any-compares? compare? num (rest nums)))]))