;; is this a correct definition? (define (x y z) (* y (+ z 5))) (x 2 3) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Define a function that, given a number of hours h, minutes m, and ;; seconds s, computes the total number of seconds in the time ;; interval. ;; Example: given h = 10, m = 15, s = 20, the expected value is ;; 36920 (define (total-sec hours minutes secs) (+ (* hours 3600) (* minutes 60) secs) ) (check-expect (total-sec 10 15 20) 36920) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; define a structure card that has a suit (a symbol 'Spades, 'Hearts, ;; 'Diamnods, 'Clubs) and a numeric value 2, 3, .., 10, 11 (= J), ;; 12 (= Q), 13 (= K), 14 (= A) (define-struct card (suit value)) (card-suit (make-card 'Spades 5)) ;; define a function "match?" that takes two cards and returns true if they have ;; the same suit or the same value (or both), false otherwise (define (match? card1 card2) (or (symbol=? (card-suit card1) (card-suit card2)) (= (card-value card1) (card-value card2)) ) ) (check-expect (match? (make-card 'Spades 5) (make-card 'Spades 10)) true) (check-expect (match? (make-card 'Spades 5) (make-card 'Diamnods 5)) true) (check-expect (match? (make-card 'Spades 12) (make-card 'Diamnods 5)) false) (check-expect (match? (make-card 'Spades 10) (make-card 'Spades 10)) true) ;; define an "isValidCard?" function that takes a card structure and ;; returns true if the card has a valid suit and a valid value and ;; false otherwise. Your function must not fail on any data. (define (isValidCard? input) (cond [(not (card? input)) false] [(not (symbol? (card-suit input))) false] ;; unfinished ;; could also be done using "and" in a combination ;; with cond or without ) ) ;(check-expect (isValidCard? (make-card 'Spades 5)) true) (check-expect (isValidCard? 5) false) (check-expect (isValidCard? (make-card 'Spades 'Hearts)) false) (check-expect (isValidCard? (make-card 4 5)) false) (check-expect (isValidCard? (make-card 'Spades -3)) false) (check-expect (isValidCard? (make-card 'Apple 3)) false)