svn: r9441
This commit is contained in:
parent
910a0ff677
commit
ca3e7cb8c7
|
@ -1,71 +0,0 @@
|
|||
{ (define LIBNAME "Arrows")
|
||||
(include "head.tinc") }
|
||||
|
||||
<p>A shape is a class of data for which <code>move</code> and
|
||||
<code>draw</code> operations can be drawn. </p>
|
||||
|
||||
<p>The teachpack <code>arrow.ss</code> implements controller for moving
|
||||
shapes across a canvass. It provides three operations:
|
||||
<menu>
|
||||
<li> <code>{(idx control-left-right)} : shape number move draw -> true </code>:
|
||||
|
||||
<br> It consumes a shape, a number, a <code>move</code> function and a
|
||||
<code>draw</code> function. The
|
||||
move function consumes a number and a shape and re-draws the shape on
|
||||
some canvas and produces a shape that is translated by N pixels left or
|
||||
right.
|
||||
<br><br>
|
||||
|
||||
<li> <code>{(idx control-up-down)} : shape number move -> true</code>:
|
||||
|
||||
<br> It is like <code>control-left-right</code> but controls movements by
|
||||
N pixels up or down.
|
||||
<br><br>
|
||||
|
||||
<li> <code>{(idx control)} : shape number move-lr move-ud -> true</code>:
|
||||
|
||||
<br> It consumes a shape, a number, two <code>move</code> functions, and a
|
||||
draw function. The <code>move</code> functions consume a number and a
|
||||
shape and re-draw the shape on some canvas and produces a shape that is
|
||||
translated by N pixels left or right and up or down, respectively.
|
||||
|
||||
</menu>
|
||||
|
||||
<p>Example:
|
||||
<pre>
|
||||
;; 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))
|
||||
|
||||
;; TESTS:
|
||||
|
||||
;; this creates the canvas
|
||||
(start 100 50)
|
||||
|
||||
;; this creates the controller GUI
|
||||
(control-left-right (make-posn 10 20) 10 move draw-it)
|
||||
</pre>
|
||||
|
||||
{(include "foot.tinc")}
|
|
@ -22,10 +22,14 @@
|
|||
@include-section["gui.scrbl"]
|
||||
@include-section["arrow-gui.scrbl"]
|
||||
@include-section["elevator.scrbl"]
|
||||
@include-section["show-queen.scrbl"]
|
||||
|
||||
@;-- what do those do? --
|
||||
|
||||
@;include-section["guess-gui.scrbl"]
|
||||
@;include-section["lkip-gui.scrbl"]
|
||||
|
||||
|
||||
@;include-section["Simplified Scheme Web Servlets"]
|
||||
@;include-section["Scheme Web Servlets"]
|
||||
@;include-section["queen.scrbl"]
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Teachpacks for How to Design Programs</title>
|
||||
</head>
|
||||
<body bgcolor="#ffffff" text="#000000" link="#009900" vlink="#007700" alink="#cc0000">
|
||||
<h1>Teachpacks for How to Design Programs</h1>
|
||||
|
||||
<ul>
|
||||
{ LIBLINKS ; libraries should be set before processing this file }</ul>
|
||||
|
||||
{(include "foot.tinc")}
|
|
@ -1,57 +0,0 @@
|
|||
#lang scribble/doc
|
||||
|
||||
@(require scribble/manual
|
||||
(for-label scheme/base))
|
||||
|
||||
@title[#:tag "questions"]{Questions concerning scribble}
|
||||
|
||||
Here are my questions. Feel free to point me to specific pieces of
|
||||
documentations. As a matter of fact, I'd almost prefer that.
|
||||
|
||||
@itemize{
|
||||
|
||||
@item{
|
||||
world.ss imports image.ss and re-exports all the bindings.
|
||||
|
||||
So in world.scrbl, I have to require @scheme[(for-label "world.ss")] but
|
||||
when I do so, I don't get bindings for functions from
|
||||
@scheme[image.ss].
|
||||
|
||||
If I require @scheme[(for-label "image.ss")] in addition, I get an
|
||||
import conflict. What is the proper solution?
|
||||
}
|
||||
|
||||
@item{
|
||||
I'd like to make graphical examples. I looked at the "quick" guide to
|
||||
see how you do this, but I can't figure out how to run all this under
|
||||
mred's control.
|
||||
}
|
||||
|
||||
@item{
|
||||
For the teachpack definitions, I like to spell out data definitions like
|
||||
in HowToDesign. For example,
|
||||
|
||||
|
||||
;; {Mode} is one of the following two symbols or strings:
|
||||
|
||||
;; -- @scheme['solid]
|
||||
|
||||
;; -- @scheme['outline]
|
||||
|
||||
;; -- @scheme["solid"]
|
||||
|
||||
;; -- @scheme["outline"]
|
||||
|
||||
I want the two semi-colons, I want the scheme mode for the constants,
|
||||
and I want the first part to look like an ordinary test line.
|
||||
[slatex and thtml do this for me]
|
||||
|
||||
I would also like to use @scheme[Mode] as if it were some exported
|
||||
variable so that I can jump to its definition from other places in the
|
||||
documentation. But I also don't want to introduce a (fake) visible
|
||||
definition. I don't think deftech and defterm are the right tools. But
|
||||
perhaps that's all there is to it.
|
||||
|
||||
}
|
||||
|
||||
}
|
26
collects/teachpack/htdp/Docs/show-queen.scrbl
Normal file
26
collects/teachpack/htdp/Docs/show-queen.scrbl
Normal file
|
@ -0,0 +1,26 @@
|
|||
#lang scribble/doc
|
||||
|
||||
@(require scribble/manual
|
||||
(for-label scheme
|
||||
teachpack/htdp/show-queen))
|
||||
|
||||
@title[#:tag "show-queen"]{8 Queens: show-queen.ss}
|
||||
|
||||
@declare-exporting[teachpack/htdp/show-queen]
|
||||
|
||||
The teachpack provides the operation @scheme[show-queen], which implements
|
||||
a GUI for exploring the n-queens problem.
|
||||
|
||||
@defproc[(show-queen [board (list-of (list-of boolean?))]) true]{The
|
||||
function @scheme[show-queen] consumes a list of
|
||||
lists of booleans that describes a @scheme[board]. Each of the inner
|
||||
lists must have the same length as the outer list. The
|
||||
@scheme[true]s correspond to positions where queens are,
|
||||
and the @scheme[false]s correspond to empty squares. The
|
||||
function returns nothing.
|
||||
|
||||
In the GUI window that @scheme[show-queen] opens, the
|
||||
red and orange dots show where the queens are. The green dot
|
||||
shows where the mouse cursor is. Each queen that threatens
|
||||
the green spot is shown in red, and the queens that do not
|
||||
threaten the green spot are shown in orange.}
|
|
@ -1,21 +0,0 @@
|
|||
{ (define LIBNAME "Show Queen")
|
||||
(include "head.tinc") }
|
||||
|
||||
<p>The teachpack <code>show-queen.ss</code> provides the
|
||||
operation <code>{(idx show-queen)}</code>. It implements a GUI for
|
||||
exploring the n-queens problem.</p>
|
||||
|
||||
<p>The function <code>show-queen</code> consumes a list of
|
||||
lists of booleans that describes a board. Each of the inner
|
||||
lists must have the same length as the outer list. The
|
||||
<code>true</code>s correspond to positions where queens are,
|
||||
and the <code>false</code>s correspond to empty squares. The
|
||||
function returns nothing.
|
||||
|
||||
<p>In the GUI window that <code>show-queen</code> opens, the
|
||||
red and orange dots show where the queens are. The green dot
|
||||
shows where the mouse cursor is. Each queen that threatens
|
||||
the green spot is shown in red, and the queens that do not
|
||||
threaten the green spot are shown in orange.
|
||||
|
||||
{(include "foot.tinc")}
|
Loading…
Reference in New Issue
Block a user