1.3 Converting Temperatures: "convert.rkt"
The teachpack convert.rkt provides three functions for
converting Fahrenheit temperatures to Celsius. It is useful for a single
exercise in HtDP. Its purpose is to demonstrate the independence of
“form” (user interface) and “function” (also known as “model”).
conversion function from Fahrenheit to Celsius and creates a graphical user
interface with two rulers, which users can use to convert temperatures
according to the given temperature conversion function.
conversion function from Fahrenheit to Celsius and then starts a
read-evaluate-print loop. The loop prompts users to enter a number and then
converts the number according to the given temperature conversion function.
A user can exit the loop by entering “x.”
file name in, a
conversion function from Fahrenheit to Celsius, and a string
out. The program then reads all the number from
in, converts them according to convert, and prints the
results to the newly created file out.
Warning: If out already exists, it is deleted.
Example: Create a file with name "in.dat" with some numbers in
it, using your favorite text editor on your computer. Define a function
f2c in the Definitions window and set teachpack to
"convert.rkt" and click Run. Then evaluate
Finally inspect the file "out.dat" and use the repl to check the