On this page:
Don’t you want it?
Making ripples
6.10.1

Lab 6: More Fun with Files and Lists

Important Note Whenever we say to "design a function", we mean that you need to follow the design recipe. Any other time that you write a function in this class, you also need to follow the design recipe.

Don’t you want it?

Recall data definitions for lists from class.

Exercise 1 Write down the data definition for a ListOfString. Write down the template for a function that processes a ListOfString.

Exercise 2 Design a function has-word? which consumes a ListOfString and a String, returning true if the given string is in the given list and false otherwise.

Exercise 3 Download the following five text files into the same folder as the file where you are completing this assignment:
Define a constant ListOfString called file-names containing the names of these files. You can use these names in your check-expect tests for later problems.

Exercise 4 Design a function file-has-word? which takes two Strings (a file name and a word to search for) and returns true if the corresponding file contains the given word.

You will need to use the 2htdp/batch-io package to examine the contents of files. You should use the built-in read-words function to create a ListOfString from a text file.

Exercise 5 Design a function search-files which takes a ListOfString (a list of file names) and a String (a word to search for) and produces a ListOfString that contains only those file names corresponding to files that contain the given String. In your check-expect tests, only use the names of the files you just downloaded.

Exercise 6 Use search-files to compute which of the files in file-names contain the word "it". Include this list with your submission.

Making ripples

For this exercise, you’ll be using big-bang to create a world which starts out as an empty scene, and creates growing circular ripples everywhere you click on the screen. The ripples should be a hollow circles that start with radius 1 and grow bigger as time passes.

Exercise 7 Come up with a data definition appropriate for representing the world in this program.

Exercise 8 Write the template for processing this data definition.

Exercise 9 Design the to-draw, on-tick, and on-mouse functions for this big-bang program and write the big-bang expression.