{"size": 1110, "ext": "scrbl", "max_stars_repo_path": "htdp-doc/teachpack/htdp/scribblings/elevator.scrbl", "max_stars_repo_name": "bdeket/htdp", "max_stars_repo_stars_event_min_datetime": "2015-01-14T20:28:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T04:04:26.000Z", "max_issues_repo_path": "htdp-doc/teachpack/htdp/scribblings/elevator.scrbl", "max_issues_repo_name": "bdeket/htdp", "max_issues_repo_issues_event_min_datetime": "2015-01-14T19:50:21.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-19T21:38:00.000Z", "max_forks_repo_path": "htdp-doc/teachpack/htdp/scribblings/elevator.scrbl", "max_forks_repo_name": "bdeket/htdp", "max_forks_repo_forks_event_min_datetime": "2015-01-14T19:11:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T05:11:39.000Z"}
{"max_stars_count": 85, "max_issues_count": 132, "max_forks_count": 81, "avg_line_length": 34.6875, "max_line_length": 75, "alphanum_fraction": 0.7783783784}
#lang scribble/doc

@(require scribble/manual "shared.rkt"
          (for-label racket teachpack/htdp/elevator))

@teachpack["elevator"]{Controlling an Elevator}

@;declare-exporting[teachpack/htdp/elevator]
@defmodule[#:require-form beginner-require 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 @racket[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:

@racketblock[(define (controller x y z) 7)]

It moves the elevator once, to the 7th floor.

Second, set the teachpack to @filepath{elevator.rkt}, click Run, and
evaluate
@racketblock[(run controller)]
