Fundamentals of CS I (CS151 2002F)

Homework 5: A Literary Web Service

Assigned: Friday, October 11, 2002
Due: Friday, October 18, 2002

Contents

Preliminaries

Summmary: In this homework assignment, you will build a simple Web service that allows someone to enter some basic information about an author (name, year of birth, year of death) and receive a list of contemporaries that the service knows about.

There are three parts to the assignment. In the first part of the assignment, you will build the Scheme functions that can be used to identify contemporaries. In the second part, you will build the Web interface. In the third part, you'll test your work using some simple inputs.

Purposes: To give you more exprience writing procedures that extract data from lists. To give you more experience relating your Web/CGI knowledge to your Scheme knowledge.

Collaboration: You should work in groups of two or three. You may not work alone (this means you, Phil). You may not work in groups of four. You may discuss your work and the assignment with anyone you wish. You may obtain help from anyone you wish, but you should clearly document that help, preferably in the introductory comments at the top of the page.

Associated file:

Part One: Identifying Contemporaries

Let's say that two authors were contemporaries just in case both of them were born before either of them died. Thus, for instance, Gabrielle D'Annunzio (1863-1938) was a contemporary of Flannery O'Connor (1935-1964), but not of Thomas Malory (d. 1471).

In this exercise, you will design, document, and write a Scheme procedure named contemporaries that takes information about an author (in the form of a three-element list comprising the author's surname, year of birth, and year of death) and a database of authors, and then searches through the database for contemporaries of that author, and returns a list of the names of any contemporaries that it finds. You may also write any helper procedures that you need, but you must comment every procedure that you write.

Here is what a typical interaction with this procedure should look like. The user wishes to see a list of the contemporaries of Francis Bacon (1561-1626).

> (contemporaries '("Bacon" 1561 1626) list-of-authors)
("Bradstreet" "Cervantes" "Corneille" "Donne" 
 "Jonson" "Marlowe" "Milton" "Moliere" "Montaigne" "Ronsard" "Shakespeare" 
 "Spenser")

In the file authors.ss, you can find a modest database containing the surnames or pseudonyms of various authors and their dates of birth and death. Again, each surname is given as a Scheme string literal and each date as a Scheme integer, and these three data about each author are assembled into a list. The database is a list of such three-element lists and is named list-of-authors. You may include this definition in your program.

The contemporaries procedure should compare its argument successively to each entry in the database. Whenever it detects a contemporary, it should select the surname or pseudonym from the database and add it to the result list.

Part Two: Web Interface

Build a Web-based interface for contemporaries. Your interface should allow someone to enter information on an author in a Web form (last name, date of birth, date of death), click on a button, and get a nicely displayed list of contemporaries.

It is likely that you will need to create three files,

Your Scheme program will probably need to include procedures that turn an individual author entry into HTML and that turn a sequence of author entries into HTML.

Note that you may want to consider building a variant of contemporaries that returns a list of matching entries, rather than a list of names. (You should still keep the original version of contemporaries somewhere in your program, even if you don't use it.)

Part Three: Testing

Use your program to find the contemporaries of

 

History

Thursday, 10 October 2002 [Samuel A. Rebelsky]

Friday, 11 October 2002 [Samuel A. Rebelsky]

 

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 Wed Dec 4 08:45:36 2002.
The source to the document was last modified on Fri Oct 11 08:43:10 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2002F/Homework/hw.05.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu