;; 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-reader.ss" "lang")((modname lec16) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; includes? : X list-of-X -> bool (define (includes? who los) (cond [(empty? los) false] [(cons? los) (or (equal? (first los) who) (includes? who (rest los)))])) ;; `includes?' is actually built in as `member' (check-expect (includes? (make-posn 1 2) empty) false) (check-expect (includes? (make-posn 1 2) (list (make-posn 7 8) (make-posn 1 2))) true) ;; got-milk? : list-of-symbol -> bool (define (got-milk? los) (includes? 'milk los)) (check-expect (got-milk? empty) false) (check-expect (got-milk? '(milk)) true) (check-expect (got-milk? '(eggs bacon)) false) (check-expect (got-milk? '(eggs milk bacon)) true) ;; includes-person? : string list-of-string -> bool (define (includes-person? who los) (includes? who los)) (check-expect (includes-person? "Mario" empty) false) (check-expect (includes-person? "Mario" '("Mario")) true) (check-expect (includes-person? "Mario" '("Luigi" "Bowser")) false) (check-expect (includes-person? "Mario" '("Luigi" "Mario" "Bowser")) true)