;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname 16.5.1) (read-case-sensitive #t) (teachpacks ((lib "testing.ss" "teachpack" "htdp"))) (htdp-settings #8(#t constructor repeating-decimal #f #t none #f ((lib "testing.ss" "teachpack" "htdp"))))) ;Worked exercise 16.5.1 ; A person has a first and last name (both strings) and an age (a number) (define-struct person (first last age)) ; make-person : string(first) string(last) number(age) -> person ; person-first : person -> string ; person-last : person -> string ; person-age : person -> number ; person? : object -> boolean #| (define (function-on-person who) ; who a person ; (person-first who) a string ; (person-last who) a string ; (person-age who) a number ) |# ; can-vote? : person -> boolean (define (can-vote? who) ; who a person ; (person-first who) a string ; (person-last who) a string ; (person-age who) a number ; 18 a fixed number (>= (person-age who) 18) ) (check-expect (can-vote? (make-person "Joe" "Schmoe" 17)) false) (check-expect (can-vote? (make-person "Anne" "Borderline" 18)) true) (check-expect (can-vote? (make-person "Chris" "Voter" 19)) true) (generate-report)