Convert


convert.ss

The teachpack convert.ss provides three functions:

  • convert-gui, which consumes a 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
  • convert-repl, which consumes a 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.
  • convert-file; it consumes a file name in, a conversion function from Fahrenheit to Celsius, and a string out. The program then reads a number from in, converts it according to the given temperature conversion function, and prints the result to the newly created file out.

    Warning: If out already exists, it is deleted.
  • Example: Define a function f2c in the Definitons window. Set teachpack to convert.ss and execute. Then evaluate

    > (convert-gui f2c)
    > 
    
    This will create a graphical user interface with two rulers. Slide the top one and click on convert to see the lower one move.