From de717e625dc007209986af3c351d76f3af35f811 Mon Sep 17 00:00:00 2001
From: Matthias Felleisen
Date: Wed, 23 Apr 2008 22:10:18 +0000
Subject: [PATCH] svn: r9438
---
collects/teachpack/htdp/Docs/arrow.scrbl | 74 ++++++++++++++++++++++
collects/teachpack/htdp/Docs/docs.scrbl | 42 ++++++++++++
collects/teachpack/htdp/Docs/docs.thtml | 38 -----------
collects/teachpack/htdp/Docs/hangman.scrbl | 33 ++++++++++
collects/teachpack/htdp/Docs/hangman.thtml | 22 -------
collects/teachpack/htdp/Docs/htdp.scrbl | 13 ++--
collects/teachpack/htdp/Docs/master.scrbl | 24 +++++++
collects/teachpack/htdp/Docs/master.thtml | 28 --------
8 files changed, 179 insertions(+), 95 deletions(-)
create mode 100644 collects/teachpack/htdp/Docs/arrow.scrbl
create mode 100644 collects/teachpack/htdp/Docs/docs.scrbl
delete mode 100644 collects/teachpack/htdp/Docs/docs.thtml
create mode 100644 collects/teachpack/htdp/Docs/hangman.scrbl
delete mode 100644 collects/teachpack/htdp/Docs/hangman.thtml
create mode 100644 collects/teachpack/htdp/Docs/master.scrbl
delete mode 100644 collects/teachpack/htdp/Docs/master.thtml
diff --git a/collects/teachpack/htdp/Docs/arrow.scrbl b/collects/teachpack/htdp/Docs/arrow.scrbl
new file mode 100644
index 0000000000..56e5d4674b
--- /dev/null
+++ b/collects/teachpack/htdp/Docs/arrow.scrbl
@@ -0,0 +1,74 @@
+#lang scribble/doc
+
+@(require scribble/manual
+ (for-label scheme
+ teachpack/htdp/arrow))
+
+@title[#:tag "arrow"]{Managing Control Arrows: arrow.ss}
+
+@declare-exporting[teachpack/htdp/arrow]
+
+The teachpack implements a controller for moving shapes across a canvass. A
+shape is a class of data for which @scheme[move] and @scheme[draw]
+operations can be drawn.
+
+@defproc[(control-left-right
+ [shape Shape]
+ [n number?]
+ [move (-> number? Shape Shape)]
+ [draw (-> Shape true)]) true]{Moves shape @scheme[n] pixels left
+(negative) or right (positive).}
+
+@defproc[(control-up-down
+ [shape Shape]
+ [n number?]
+ [move (-> number? Shape Shape)]
+ [draw (-> Shape true)]) true]{Moves shape @scheme[n] pixels up
+(negative) or down (positive).}
+
+@defproc[(control
+ [shape Shape]
+ [n number?]
+ [move-lr (-> number? Shape Shape)]
+ [move-ud (-> number? Shape Shape)]
+ [draw (-> Shape true)]) true]{
+Moves shape @scheme[N] pixels left or right and up or down, respectively.}
+
+Example:
+@(begin
+#reader scribble/comment-reader
+(schemeblock
+;; A shape is a structure:
+;; (make-posn num num)
+
+;; RAD : the radius of the simple disk moving across a canvas
+(define RAD 10)
+
+;; move : number shape -> shape or false
+;; to move a shape by delta according to translate
+;; effect: to redraw it
+(define (move delta sh)
+ (cond
+ [(and (clear-solid-disk sh RAD)
+ (draw-solid-disk (translate sh delta) RAD))
+ (translate sh delta)]
+ [else false]))
+
+;; translate : shape number -> shape
+;; to translate a shape by delta in the x direction
+(define (translate sh delta)
+ (make-posn (+ (posn-x sh) delta) (posn-y sh)))
+
+;; draw-it : shape -> true
+;; to draw a shape on the canvas: a disk with radius
+(define (draw-it sh)
+ (draw-solid-disk sh RAD))
+
+;; RUN:
+
+;; this creates the canvas
+(start 100 50)
+
+;; this creates the controller GUI
+(control-left-right (make-posn 10 20) 10 move draw-it)
+))
diff --git a/collects/teachpack/htdp/Docs/docs.scrbl b/collects/teachpack/htdp/Docs/docs.scrbl
new file mode 100644
index 0000000000..52d979bbbf
--- /dev/null
+++ b/collects/teachpack/htdp/Docs/docs.scrbl
@@ -0,0 +1,42 @@
+#lang scribble/doc
+
+@(require scribble/manual
+ (for-label scheme
+ teachpack/htdp/docs))
+
+@title[#:tag "docs"]{Manipulating Simple HTML Documents: docs.ss}
+
+@declare-exporting[teachpack/htdp/docs]
+
+The teachpack provides three operations for creating simple ``HTML'' documents:
+
+@deftech{Annotation} An @tech{Annotation} is a symbol that starts with ``<''
+and ends in ``>''. An end annotation is one that starts with ``''.
+
+@defproc[(atom? [x any/c]) boolean?]{Determines whether or not a Scheme value
+is a number, a symbol, or a string.}
+
+@defproc[(annotation? [x any/c]) boolean?]{Determines whether or not a Scheme
+symbol is a document annotation.}
+
+@defproc[(end-annotation [x (unsyntax @tech{Annotation})]) (unsyntax @tech{Annotation})]{Consumes an annotation
+and produces a matching ending annotation.}
+
+@defproc[(write-file [l (list-of atom)]) true]{
+Consumes a list of symbols and annotations and prints them out as a
+"file".}
+
+Sample session: set teachpack to ``docs.ss''> and click RUN:
+@(begin
+#reader scribble/comment-reader
+(schemeblock
+> (annotation? 0)
+false
+> (annotation? ')
+true
+> (end-annotation 0)
+end-annotation: not an annotation: 0
+> (write-file (list 'a 'b))
+a b
+))
+
diff --git a/collects/teachpack/htdp/Docs/docs.thtml b/collects/teachpack/htdp/Docs/docs.thtml
deleted file mode 100644
index 36bcbc8f0f..0000000000
--- a/collects/teachpack/htdp/Docs/docs.thtml
+++ /dev/null
@@ -1,38 +0,0 @@
-{ (define LIBNAME "Documents")
- (include "head.tinc") }
-
-The teachpack docs.ss
provides three operations:
-
-
-Sample session: set teachpack to docs.ss
and execute:
-
-> (annotation? 0)
-#f
-> (annotation? '<bold>)
-#t
-> (end-annotation 0)
-end-annotation: not an annotation: 0
-> (write-file (list 'a 'b))
-a b
-
-
-{(include "foot.tinc")}
diff --git a/collects/teachpack/htdp/Docs/hangman.scrbl b/collects/teachpack/htdp/Docs/hangman.scrbl
new file mode 100644
index 0000000000..034c13da37
--- /dev/null
+++ b/collects/teachpack/htdp/Docs/hangman.scrbl
@@ -0,0 +1,33 @@
+#lang scribble/doc
+
+@(require scribble/manual
+ (for-label scheme
+ teachpack/htdp/hangman))
+
+@title[#:tag "hangman"]{Hangman : hangman.ss}
+
+@declare-exporting[teachpack/htdp/hangman]
+
+The teachpack implements the callback functions for playing a
+@emph{Hangman} game, based on a function designed by a student. The player
+guesses a letter and the program responds with an answer that indicates
+how many times, if at all, the letter occurs in the secret word.
+
+The teachpack provides all the drawing operations from @secref{draw} for
+managing a canvas into which the ``hangman'' is drawn.
+
+@defproc[(hangman [make-word (-> symbol? symbol? symbol? word?)][reveal (-> word? word? boolean?)][draw-next-part (-> symbol? true)]) true]{
+Chooses a ``secret'' three-letter word and uses the given functions to
+manage the @emph{Hangman} game.}
+
+@defproc[(hangman-list
+ [reveal-for-list (-> symbol? (list-of symbol?) (list-of symbol?)
+ boolean?)]
+ [draw-next-part (-> symbol? true)]) true]{
+Chooses a ``secret'' word---a list of symbolic letters---and uses the given
+functions to manage the @emph{Hangman} game:
+@scheme[reveal-for-list] determines how many times the chosen letter occurs
+in the secret word;
+@scheme[draw-next-part] is given the symbolic name of a body part and draws
+it on a separately managed canvas.
+}
diff --git a/collects/teachpack/htdp/Docs/hangman.thtml b/collects/teachpack/htdp/Docs/hangman.thtml
deleted file mode 100644
index 6049d93bc5..0000000000
--- a/collects/teachpack/htdp/Docs/hangman.thtml
+++ /dev/null
@@ -1,22 +0,0 @@
-{ (define LIBNAME "Hangman")
- (include "head.tinc") }
-
-The teachpack hangman.ss
provides all the operations that
-draw.ss
provides and the following two:
-
-
-
-{(include "foot.tinc")}
diff --git a/collects/teachpack/htdp/Docs/htdp.scrbl b/collects/teachpack/htdp/Docs/htdp.scrbl
index 7dcc4a19b2..7d984469ab 100644
--- a/collects/teachpack/htdp/Docs/htdp.scrbl
+++ b/collects/teachpack/htdp/Docs/htdp.scrbl
@@ -12,11 +12,12 @@
@include-section["convert.scrbl"]
@include-section["guess.scrbl"]
-@;include-section["mastermind.scrbl"]
+@include-section["master.scrbl"]
@include-section["draw.scrbl"]
-@;include-section["hangman.scrbl"]
-@;include-section["arrows.scrbl"]
-@;include-section["documents.scrbl"]
+@include-section["hangman.scrbl"]
+@include-section["arrow.scrbl"]
+@include-section["docs.scrbl"]
+
@;include-section["files-directories.scrbl"]
@;include-section["graphing.scrbl"]
@;include-section["gui.scrbl"]
@@ -24,9 +25,7 @@
@;include-section["arrows-gui.scrbl"]
@;include-section["guess-gui.scrbl"]
@;include-section["elevator.scrbl"]
+
@;include-section["Simplified Scheme Web Servlets"
@;include-section["Scheme Web Servlets"
@;include-section["queen.scrbl"]
-
-
-@;include-section["testing.scrbl"
diff --git a/collects/teachpack/htdp/Docs/master.scrbl b/collects/teachpack/htdp/Docs/master.scrbl
new file mode 100644
index 0000000000..8d7f5a5d52
--- /dev/null
+++ b/collects/teachpack/htdp/Docs/master.scrbl
@@ -0,0 +1,24 @@
+#lang scribble/doc
+
+@(require scribble/manual
+ (for-label scheme
+ teachpack/htdp/master))
+
+@title[#:tag "master"]{MasterMinding : master.ss}
+
+@declare-exporting[teachpack/htdp/master]
+
+The teachpack implements GUI for playing a simple master mind-like game,
+based on a function designed by a student. The player clicks on two colors
+and the program responds with an answer that indicates how many colors and
+places were correct.
+
+@defproc[(master [check-guess (-> symbol? symbol? symbol? symbol? boolean?)]) symbol?]{
+Chooses two ``secret'' colors and then opens a graphical user interface for
+playing @emph{MasterMind}. The player is prompted to choose two colors, via
+a choice tablet and mouse clicks. Once chosen, @scheme[master] uses
+@scheme[check-guess] to compare them.
+
+If the two guesses completely match the two secret colors,
+@scheme[check-guess] must return @scheme['PerfectGuess]; otherwise it must
+return a different, informative symbol.}
diff --git a/collects/teachpack/htdp/Docs/master.thtml b/collects/teachpack/htdp/Docs/master.thtml
deleted file mode 100644
index 88493ed4d1..0000000000
--- a/collects/teachpack/htdp/Docs/master.thtml
+++ /dev/null
@@ -1,28 +0,0 @@
-{ (define LIBNAME "Mastermind")
- (include "head.tinc") }
-
-The teachpack master.ss
provides the operation
-master
. It implements a GUI for playing a simple
-master mind-like game. The player clicks on two colors and the
-program responds with an answer that indicates how many colors
-and places were correct.
-
-The function master
consumes the function
-check-guess
, which is the key component of
-TeachMasterMind. The function check-guess
consumes the two
-colors that the player guessed and the two players that the master chose
-(randomly at the beginning of the game). It compares the colors and
-produces an appropriate symbol.
-
-The teachpack provides only one operation:
-
-
-{(include "foot.tinc")}