racket/teachpack/htdp/Docs/convert.thtml
2005-05-27 17:52:04 +00:00

41 lines
1.6 KiB
Plaintext

{ (define LIBNAME "Convert")
(include "head.tinc") }
<p>The teachpack <code>convert.ss</code> provides three functions:
<menu>
<li> <code>{(idx convert-gui)}</code>, 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
<li> <code>{(idx convert-repl)}</code>, 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 <code>x</code>.
<li> <code>{(idx convert-file)}</code>; it consumes a file name <code>in</code>, a
conversion function from Fahrenheit to Celsius, and a string
<code>out</code>. The program then reads a number from
<code>in</code>, converts it according to the given temperature
conversion function, and prints the result to the newly created file
<code>out</code>. <br>
<br><b>Warning:</b> If <code>out</code> already exists, it is
deleted.
</menu>
<p>Example: Define a function <code>f2c</code> in the Definitons window.
Set teachpack to <code>convert.ss</code> and execute. Then evaluate
<pre>
> (convert-gui f2c)
>
</pre>
This will create a graphical user interface with two rulers. Slide the top
one and click on convert to see the lower one move.</p>
{(include "foot.tinc")}