;; functions that check types (number? -0.98) (number? (+ 4 -77)) (number? 4/3) (integer? 3.14) (real? 3.14) (integer? 8/2) (exact? 3.14) (exact? 8/2) (exact? 1/3) (exact? (sin 5)) (exact? (ceiling (sin 5))) (boolean? true) (boolean? 'true) (symbol? 'yes) (symbol? 5) (symbol? "yes") ;; using type checks in functions ;; Contract: number -> number (or symbol on error) ;; Purpose: to compute the square root of the cube ;; of a number. If the parameter is not a number or ;; is negative returns a symbol to signal an error (define (sqrt-of-cube x) (cond [(not (number? x)) 'NotANumber] [(< x 0) 'NoRootOfNegativeNumber] [else (sqrt (* x x x))] ) ) (check-expect (sqrt-of-cube "banana") 'NotANumber)