parrot fish faceoff images

Domesticating, parameterizing, and composing definitions in racket/scheme

The video tutorials below are to help you learn how to design definitions to stand for values or functions, and how to compose functions. Of course you should get DrRacket for your computer platform, to work through the examples.

In case videos aren't your preferred source for learning, I've also included some other resources with each video.

define identifiers for values video

Define identifiers to stand for elephant images, lucky numbers, long passages of words. When you're done with the video, you should be able to:

  • Define an identifier pingu to stand for an image that you paste into DrRacket. It would be appropriate, but not required, if the image were of a penguin.
  • Define an identifier boring to stand for the smallest positive, uninteresting whole number that you can think of.
  • Define an identifier double-pingu that stands for pingu beside him/her/itself.
  • Define an identifier fine-print that stands for a paragraph of legal jargon that you find or make up.

Some non-video resources relevant to this topic:

compose output as input video

Some function applications have other function applications within them. The inner applications have to be evaluated first, then the outer ones. Once you're done with the video, you should be able to:

  • Calculate the sum of 149 divided by 7 with 83 times 15.
  • Append the first six characters of "sixty-five" to the first two characters of "twenty"
  • Take an image, place it beside a horizontally-flipped version of itself. Then take the image you produced from the previous sentence and place it above a vertically flipped version of itself.

Some non-video resources relevant to this topic:

define function without design video

Instead of re-doing tedious sequences of instructions by hand you can define a function where the information about what changes is in a place-holder. Once you're done with the video, you should be able to:

  • Define a function called shrinking that places a 1/2-scale copy of an image beside itself.
  • Define a function called mirror-rosette that produces the mirror image (left to right) of rosette

Some non-video resources relevant to this topic:

define a function using design recipe video

You just can't go on using the seat-of-the-pants approach to creating functions from the last video. Here's a step-by-step recipe for designing a function. When you're done with the video, you should be able to follow all the design steps to:

  • Design a function half-flip that takes an image as input, and produces the same image, scaled to half its size, and flipped horizontally. Be sure to begin with a contract, purpose statement, and check-expect.

Some non-video resources relevant to this topic:

  • Chapter 5 of Stephen Bloch's Picturing Programs

Stephen Bloch's mirror-image function

mirror-image video walks you through defining a function to put any image beside a mirror image of itself.

Danny Heap
Last modified: Thu Aug 23 10:06:27 EDT 2012