MCS-177 Lab: Quilting


This lab is based on sections 1.3 and 2.4 of the text, with one exercise from section 3.1. You should be able to make a good start on the lab using the material from chapter 1. Take a look at section 2.4 before the second lab period (Thursday); we'll be discussing it in class on Friday, but you'll likely be getting that far in lab Thursday.

In this lab, you will build procedures that operate on rectangular images, rather than numbers. Using these procedures you'll produce geometric quilt patterns, such as the Repeating Crosses pattern shown on page 15 of the text.


Before coming to lab,  read this handout and section 1.3 carefully. Think about the procedures you have to define, and how they might be accomplished. Don't worry if you can't figure them out in advance; you'll have an easier time once you've gained some experience playing around with the images in lab.

In lab

  1. Launch DrScheme. We recommend using the definition window for all of your definitions and using the interaction window only for quick experiments which you are unlikely to repeat. Save the program file early and often.
  2. To load into Scheme the definitions of the basic blocks, evaluate the following expression:
    (load "~mc27/labs/quilting/quilting.scm")
    by typing the line into your definition window and hitting execute. Now you should be able to see each block by evaluating its name in the interaction window. In adddition to the blocks mentioned in the book, we have also included two solid blocks, black-bb and white-bb.
  3. The stack and quarter-turn-right procedures are built into our Scheme. Try them out as in exercise 1.8 on page 16 of the text, and make sure you understand what each does and how combinations behave. (We should point out here that the code from the book is available from the web page ; simply follow the link for the chapter you want. Using these files will substantially reduce your typing.) Note that names such as rcross-bb continue to name the same, unmodified basic block throughout. The procedures give you back transformed copies of the image rather than changing the original image in any way. Write a precise description of what each of these two primitive procedures does.
  4. Do exercise 1.9 on pages 16-17. (We'll bring the card-stock basic blocks to lab to help you think these through.)

    Be sure to save your definition window early and often.  (Just click the Save button.) Note that the next time you use DrScheme, you can simply open this file by using the File menu.

  5. Do exercise 1.10 (page 17).
  6. Do exercise 2.13 (page 40).
  7. Do exercise 2.14 (page 40).
  8. Do exercise 2.15 (page 42). Note: be sure to carefully read the paragraph preceding exercise 2.15 before starting to program.
  9. Do exercise 3.3 (page 54).


Write a lab report that does a clear job of communicating your results to a reader who is generally knowledgeable about Scheme, but ignorant of what specific things you've done. Your report should include the procedures you wrote, illustrations of their results, and answers to the questions scattered throughout the ``In Lab'' section.

We've included two documents to give you a better sense for what we expect from your lab write-up. The first is a sample write-up for a much shorter lab. This sample write-up was done using Schematik, a program somewhat like DrScheme that we used in earlier years. Like DrScheme, Schematik isn't really a word processor, so the appearance isn't very fancy. However, we'd be satisfied with this. If you really want to do something similar to this with DrScheme, we have a separate document with tips on doing so.

On the other hand, it isn't really very hard to make a fancier report using on a word processor, such as Applix on the Linux machines, and we recommend doing so. The lab assistants should be able to help you questions you might have about using this word processor. You should use Copy and Paste to get your Scheme definitions into the word processor, rather than manually retyping them. Students who retype inevitably make typos and wind up handing in procedures that couldn't possibly have worked. Additionally, Applix has a "Snap to clipboard" feature in the Edit menu that lets you take a snapshot of a portion of the screen, which you can then Paste in. This can be used to include the images from DrScheme's interaction window. Put your Scheme procedures into the ``Courier'' font. In this font, every character is the same width (like on a typewriter, or in the DrScheme program), so the indentation will line up correctly. If you have problems getting Applix to print, your "preference" settings may not be configured right; a lab assistant should be able to help with this.

The other document to consult is entitled Suggestions for clear lab reports in computer science courses, which pretty much says it all.

In general, be sure to read through your report and fix any problems you find, either in general presentation or in spelling and grammar. Not only do spelling and grammar errors detract from the clarity of your report, they suggest that you judged the report not to be worth the time to read. If you aren't willing to read your own report, who will be?

If you have time

  1. To produce your own basic blocks, see exercise 1.11 on pages 17-18. (Sorry, we don't have any way of providing graphical input to Scheme.)
  2. You may find other interesting ways to replicate images beyond pinwheeling and checkerboarding. For example, you could combine rotated versions of a basic block, some of which have been inverted and others not. You might also try using the built-in procedure mirror-image. Be creative!