CS 1101 - Aterm 08

Homework 4 - Basic Lists

Due: Tuesday, Sept 16 at 11:59pm

Read the expectations on homework.

Assignment Goals


The Assignment

Writing Programs over Lists

Imagine that you are writing programs that are part of a word game (like Scrabble or Boggle) in which players get points for the words they can come up with during the game.
  1. Write the data definition and template for list-of-word.

  2. Write a function got-word? that consumes a list of words and a word and produces a boolean indicating whether the given word is in the list.

  3. Write a function found-duplicate? that consumes a list of words and a word and produces a boolean indicating whether or not the given word occurs at least twice in the list. (Hint: use your answer to Problem 2)

Download the teachpack string-extras.scm . It provides a function char-count that consumes a string of length 1 and a string of any length and produces a number indicating how many times the first string appears in the second string. You'll need it in the remaining problems.

  1. Write a function words-with-zs that consumes a list of words and produces a list of only those words from the original list which contain the letter z.

  2. Write a function count-by-letters that consumes two letters (strings of length 1 like "e" or "s") and a list of words and produces the total number of words in the list that contain both of the letters.

  3. Write a function score-list that consumes a list of words and produces the score for that list of words according to the following criteria: words are scored by giving one point each per letter, except "z", which is worth 5 points. If the list contains more than 5 words, a bonus of 10 points is added. (Hint: break this problem up into pieces. Write helper functions to do each piece.)


What to Turn In

Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Follow the naming conventions when naming your file. Files should be submitted using turnin's group submit option. Please put both partners' names and wpi login names in a comment at the top of the file.