# Assignment 8: Building Lists of Positions and Spots

Due: 4:00 p.m., Tuesday, 2 October 2007
No extensions!

This homework is also available in PDF.

Summary: In this assignment, you will further explore the construction and use of spot lists.

Purposes: To give you experience thinking about lists of spots. To give you experience with `map`.

Expected Time: One hour

Collaboration: I encourage you to work in groups of size three. You may, however, work alone or work in a group of size two or size four. You may discuss this assignment with anyone, provided you credit such discussions when you submit the assignment.

Warning: So that this assignment is a learning experience for everyone, I may spend class time publicly critiquing your work.

Contents:

## Assignment

In our recent labs, you have experimented with creating and manipulating spots, triplets of the form (column row color). We've seen how to draw a sequence of spots, to enlarge spots (and draw a sequence of enlarged spots), and even to translate lists of spots.

Of course, some people have difficulty coming up with interesting collections of spots. Hence, we might write a procedure that helps us do so.

a. Write a procedure, `(image.get-spot image pos)`, that, given an image and a position, gets the spot at the given position.

b. Write a procedure, `(image.get-spots image list-of-positions)`, that gets a list of spots from an image, using a list of positions to indicate which spots to get. Note that you can write this using `map` and `image.get-spot`.

c. Write a procedure, `(position.right-of pos offset)`, that, given a position and an offset, finds the position offset columns to the right of pos.

d. Write a procedure, `(position.below pos offset)`, that, given a position and an offset, finds the position offset rows below pos.

e. Write a procedure, `(position.row-of-10 pos)`, that, given a position, makes a list of the ten positions in a row, starting at pos and going to the right. Your procedure will look something like:

```(define position.row-of-10
(lambda (pos)
(list pos
(position.right-of pos 1)
(position.right-of pos 2)
...)))
```

f. Write a procedure, `(image.get-row-of-ten-spots image starting-pos)`, that gets ten spots in a row from image, starting at starting-pos. You should use `image.get-spots` and `position.row-of-10` to build this procedure.

g. Using `image.get-row-of-ten-spots`, grab a few rows from an image of your choice and then draw them again (offset horizontally and vertically) in a new image.

## Important Evaluation Criteria

I will primarily look to see that your code is correct. I will also consider whether you've found a way to use `image.get-row-of-ten-spots` to draw interesting images.

Please submit this work via email. The email should be titled CSC151.02 Assignment 8 and should contain your answers to all parts of this assignment.

Please send your code as the body of an email message. You should also attach your source image, your result image, and the code you used to create the result.

## History

Thursday, 27 September 2007 [Samuel A. Rebelsky]

• Created.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Mon Dec 3 09:56:00 2007.
The source to the document was last modified on Mon Oct 1 10:55:47 2007.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2007F/Assignments/assignment.08.html`.

You may wish to validate this document's HTML ; ;

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2007 Janet Davis, Matthew Kluber, and Samuel A. Rebelsky. (Selected materials copyright by John David Stone and Henry Walker and used by permission.) This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation. This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit `http://creativecommons.org/licenses/by-nc/2.5/` or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.