Exercise 4.2.4: (back)
;; Fahrenheit->Celsius : number -> number ;; Example : (Fahrenheit->Celsius 32) -> 0 (define (Fahrenheit->Celsius t) (* (- t 32) (/ 5 9))) ;; test-fahrenheit->celsius : number -> number ;; Example : (test-fahrenheit->celsius 32) -> true ;; Example : (test-fahrenheit->celsius 30) -> false (define (test-fahrenheit->celsius t) (= (Fahrenheit->Celsius t) 0))
;; dollar->euro : number -> number ;; Example : (dollar->euro 1) -> 0.633 (define (dollar->euro x) (* x 0.633)) ;; test-dollar->euro : number -> number ;; Example : (test-dollar->euro 1) -> true ;; Example : (test-dollar->euro 0.633) -> false (define (test-dollar->euro x) (= (dollar->euro x) 0.633))
;; triangle : number number -> number ;; Example : (triangle 2 3) -> 3 (define (triangle a h) (* a (/ h 2))) ;; triangle : number number -> number ;; Example : (test-triangle 2 3) -> true ;; Example : (test-triangle 4 5) -> false (define (test-triangle x y) (= (triangle x y) 3))
;; convert3 : number number number -> number ;; Example : (convert3 2 3 4) -> 432 (define (convert3 x y z) (+ x (* 10 y) (* 100 z))) ;; convert3 : number number number -> number ;; Example : (test-convert3 2 3 4) -> true ;; Example : (test-convert3 3 4 5) -> false (define (test-convert3 x y z) (= (convert3 x y z) 432))