# Homework 13: Interest Groups

This homework assignment is also available in PDF.

Assigned: Tuesday, 7 November 2006
Due: Friday, 10 November 2006
No extensions!

Summary: In this assignment, you will explore a variant mechanism for searching lists.

Purposes: To help you think more about association lists and linear search.

Expected Time: One to two hours.

Collaboration: You may work in a group of any size between one and four, inclusive. You may consult others outside your group, provided you cite those others. You need only submit one assignment per group.

Submitting: Email me your work, using a subject of CSC151 Homework 13.

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

## Background

Student government at Egelloc College has been gathering information on the dozens of student groups that they support. For each group, they have two values: the name of the group and a list of all the nicknames of students in the group. (Amazingly, no two students at Egelloc have the same nickname.) They've chosen to represent groups as strings and nicknames as symbols.

They've decided to represent each group as a list with two elements: the first is the name, the second is a list of student nicknames. To keep track of all of the student groups, they've put them into a list. For example,

```(define student-groups
(list
(list "yearbook"    (list 'camera-dan 'jane 'jack 'nick))
(list "hackers"     (list 'nick 'eryn 'cable 'ted 'emily))
(list "swing dance" (list 'eryn 'old-ian))
(list "e-tones"     (list 'vincent 'singing-dan 'jack))
(list "no-trains"   (list 'mags 'vincent))
(list "teecees"     (list 'eryn 'young-ian))))
```

Now they want ways to process the list.

## Assignment

Write a procedure, `(groups nickname)` that, given someone's nickname and a list of all student groups in the form mentioned above, returns a list of all the groups to which that student belongs.

```> (groups 'eryn)
("hackers" "swing-dance" "teecees")
> (groups 'sam)
()
```

## History

Monday, 6 November 2006 [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 Thu Nov 30 21:42:54 2006.
The source to the document was last modified on Mon Nov 6 18:46:37 2006.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2006F/Homework/hw.13.html`.

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

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2006 Samuel A. Rebelsky. 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.