33 lines
889 B
Plaintext
33 lines
889 B
Plaintext
{ (define LIBNAME "Elevator")
|
|
(include "head.tinc") }
|
|
|
|
<p>The teachpack <code>elevator.ss</code> implements an elevator simulator.
|
|
It displays an eight-floor elevator and accepts mouse clicks from the user,
|
|
which are translated into service demands for the elevator. The teachpack
|
|
provides a single operation:
|
|
<br>
|
|
<menu>
|
|
<li><code>{(idx run)} : NextFloor -> void</code>
|
|
<br>that is, it consumes an elevator controller and returns nothing .
|
|
</menu>
|
|
|
|
<br>
|
|
Sample session: First define a function that consumes the current state of
|
|
the elevator (three arguments) and returns a number between 1 and 8. Here
|
|
is a non-sensical definition:
|
|
<br> <code> (define (controller x y z) 7) </code>
|
|
<br>It moves the elevator once, to the 7th floor.
|
|
|
|
<br>
|
|
|
|
<br>Second, set the teachpack to <code>elevator.ss</code> execute and
|
|
run:
|
|
|
|
<pre>
|
|
> (run controller)
|
|
>
|
|
</pre>
|
|
<br>
|
|
|
|
{(include "foot.tinc")}
|