#lang plait (print-only-errors #t) (define (ctf [temperature : Number]) : Number (+ 32 (* 1.8 temperature))) (test (ctf 100) 212) (test (ctf 0) 32) (test (ctf 100.2) 212.36) (test (ctf 100) 212.00) (define (status [temperature : Number]) : String (cond [(< temperature 60) "cold"] [(> temperature 80) "hot"] ;This is an else [(and(>= temperature 60)(<= temperature 80)) "nice"])) (test (status 69) "nice") (test (status 60) "nice") (test (status 80) "nice") (test (status 59) "cold") (test (status 81) "hot") (define-type Temperature (celcius [deg : Number]) (fahrenheit [deg : Number])) (celcius 0) (fahrenheit 32) (define (comfortable [temp : Temperature]) (type-case Temperature temp [(celcius deg) (status (ctf deg))] [(fahrenheit deg) (status deg)])) ;We definitely needed the first and last test, but it's always nice to add more test cases. (test (comfortable (celcius 100)) "hot") (test (comfortable (celcius 25)) "nice") (test (comfortable (celcius 0)) "cold") (test (comfortable (fahrenheit 60)) "nice")