racket/collects/teachpack/htdp/scribblings/elevator.scrbl
Eli Barzilay afad5af486 * Added a `teachpack' function to do teachpack titles
* Made it add "foo teachpack" as an index entry

svn: r10687
2008-07-09 02:28:20 +00:00

32 lines
1.0 KiB
Racket

#lang scribble/doc
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/elevator))
@teachpack["elevator"]{Controlling an Elevator}
@declare-exporting[teachpack/htdp/elevator]
The teachpack 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.
@defproc[(run [NextFloor number?]) any/c]{Creates an elevator simulator
that is controlled by @scheme[NextFloor]. This function consumes the
current floor, the direction in which the elevator is moving, and the
current demands. From that, it computes where to send the elevator next.}
Example: 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:
@schemeblock[(define (controller x y z) 7)]
It moves the elevator once, to the 7th floor.
Second, set the teachpack to <code>elevator.ss</code>, click RUN, and
evaluate
@schemeblock[(run controller)]