CS 1101 - Aterm 12

Homework 3 - Unions and Simple List Processing

Due: Tuesday, September 11 at 5pm

Read the expectations on homework.

Assignment Goals


The Assignment

Writing Data Definitions for Unions

Hurricane Isaac wreaked havoc on the Gulf Coast of Louisiana last week. The country's midsection has been plagued by drought throughout the summer. In this assignment, you will create data definitions for various kinds of weather-related phenomena, and write programs over those data definitions.

A storm can be any one of the following:

Writing Programs for Unions

  1. Develop a data definition for each type of storm described above, and one for storms in general. Provide at least one example for each kind of storm.

  2. Provide the template for each data definition you made in Problem 1.

  3. Write a function fast-moving-storm? that consumes a storm and produces a boolean. The function returns true if the velocity of the storm exceeds 30 mph, otherwise it returns false.

  4. Write a function warning that consumes a storm and produces a string. The string that is produced is as follows:

  5. Write a function upgrade-category that consumes a storm and produces a storm. The storm is returned unchanged if the given storm is a thunderstorm, a tornado of severity F5, or a hurricane of category 5. Otherwise, the storm that's produced is a storm the same as the original, except that the severity or category of the new storm is at the next higher level.

Writing Programs for Simple Lists

  1. Write the data definition for a list-of-string. Provide examples of list-of-string.

  2. Write the template for functions over a list-of-string

  3. Write a function character-count that consumes a list-of-string and counts the total number of characters in all strings in the list.

  4. Write a function all-alphabetic? that consumes a list-of-string and produces true if all characters in all strings in the list are alphabetic characters. Otherwise, the function produces false. (Hint: check the DrRacket help desk for the function string-alphabetic?)

What to Turn In

Here is the grading sheet that the graders will be using for Homework 3.

Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Name your file according to the naming conventions for files. Make sure both partners' names and login names appear at the top of the file in a comment.