5.3.6

How to Design Programs Teachpacks

Teaching languages are small subsets of a full programming language. While such restrictions simplify error diagnosis and the construction of tools, they also make it impossible (or at least difficult) to write some interesting programs. To circumvent this restriction, it is possible to import teachpacks into programs written in a teaching language.

In principle, a teachpack is just a library written in the full language, not the teaching subset. Like any other library, it may export values, functions, etc. In contrast to an ordinary library, however, a teachpack must enforce the contracts of the “lowest” teaching language into which it is imported and signal errors in a way with which students are familiar at that level.

This chapter covers the teachpacks for How to Design Programs.

    1 HtDP Teachpacks

      1.1 Manipulating Images: "image.rkt"

        1.1.1 Images

        1.1.2 Modes and Colors

        1.1.3 Creating Basic Shapes

        1.1.4 Basic Image Properties

        1.1.5 Composing Images

        1.1.6 Manipulating Images

        1.1.7 Scenes

        1.1.8 Miscellaneous Image Manipulation and Creation

      1.2 Simulations and Animations: "world.rkt"

        1.2.1 Simple Simulations

        1.2.2 Interactions

        1.2.3 A First Example

          1.2.3.1 Understanding a Door

          1.2.3.2 Simulations of the World

          1.2.3.3 Simulating a Door: Data

          1.2.3.4 Simulating a Door: Functions

      1.3 Converting Temperatures: "convert.rkt"

      1.4 Guessing Numbers: "guess.rkt"

      1.5 MasterMinding: "master.rkt"

      1.6 Playing MasterMind: "master-play.rkt"

      1.7 Simple Drawing: "draw.rkt"

        1.7.1 Drawing on a Canvas

        1.7.2 Interactions with Canvas

      1.8 Hangman: "hangman.rkt"

      1.9 Playing Hangman: "hangman-play.rkt"

      1.10 Managing Control Arrows: "arrow.rkt"

      1.11 Manipulating Simple HTML Documents: "docs.rkt"

      1.12 Working with Files and Directories: "dir.rkt"

      1.13 Graphing Functions: "graphing.rkt"

      1.14 Simple Graphical User Interfaces: "gui.rkt"

      1.15 An Arrow GUI: "arrow-gui.rkt"

      1.16 Controlling an Elevator: "elevator.rkt"

      1.17 Lookup GUI: "lkup-gui.rkt"

      1.18 Guess GUI: "guess-gui.rkt"

      1.19 Queens: "show-queen.rkt"

      1.20 Matrix Functions: "matrix.rkt"

    2 HtDP/2e Teachpacks

      2.1 Batch Input/Output: "batch-io.rkt"

        2.1.1 IO Functions

        2.1.2 Testing

      2.2 Image Guide

        2.2.1 Overlaying, Above, and Beside: A House

        2.2.2 Rotating and Overlaying: A Rotary Phone Dial

        2.2.3 Alpha Blending

        2.2.4 Recursive Image Functions

        2.2.5 The Nitty Gritty of Pixels, Pens, and Lines

        2.2.6 The Nitty Gritty of Alpha Blending

      2.3 Images: "image.rkt"

        2.3.1 Basic Images

        2.3.2 Polygons

        2.3.3 Overlaying Images

        2.3.4 Placing Images & Scenes

        2.3.5 Rotating, Scaling, Flipping, Cropping, and Framing Images

        2.3.6 Bitmaps

        2.3.7 Image Properties

        2.3.8 Image Predicates

        2.3.9 Equality Testing of Images

        2.3.10 Pinholes

        2.3.11 Exporting Images to Disk

      2.4 Worlds and the Universe: "universe.rkt"

        2.4.1 Background

        2.4.2 Simple Simulations

        2.4.3 Interactions

        2.4.4 A First Sample World

          2.4.4.1 Understanding a Door

          2.4.4.2 Hints on Designing Worlds

        2.4.5 The World is not Enough

          2.4.5.1 Messages

          2.4.5.2 Sending Messages

          2.4.5.3 Connecting with the Universe

          2.4.5.4 Receiving Messages

        2.4.6 The Universe Server

          2.4.6.1 Worlds and Messages

          2.4.6.2 Universe Descriptions

          2.4.6.3 Exploring a Universe

        2.4.7 A First Sample Universe

          2.4.7.1 Two Ball Tossing Worlds

          2.4.7.2 Hints on Designing Universes

          2.4.7.3 Designing the Ball Universe

          2.4.7.4 Designing the Ball Server

          2.4.7.5 Designing the Ball World

      2.5 Planet Cute Images

        2.5.1 Characters

        2.5.2 Blocks

        2.5.3 Items

        2.5.4 Ramps

        2.5.5 Buildings

        2.5.6 Shadows

      2.6 Porting World Programs to Universe

        2.6.1 The World is Not Enough

        2.6.2 Porting World Programs

        2.6.3 Porting Image Programs