Lab 6 - Spring 2021

This week in class we learned about trees, and saw two examples of data definitions of trees: a rumor mill and a pipeline. We designed one function in class for a pipeline, which determined whether there was water running. We followed the Design Recipe and the data definition from the lecture notes. We developed a template for a function that consumes a pipeline, and returns a boolean value.

Today in lab we will write three more functions that consume pipelines, again using the template each time for a function that consumes a pipeline. The first function will turn on all the faucets, the second one will count all the faucets that are turned on, and the third will modernize the given pipeline.

How to get started

  1. Open a browser and copy/paste this URL:

  2. Login to Github and you will be prompted to accept this assignment
    1. After you click on the [Accept this assignment] button, you will see a new page display in your browser with the message:
      1. You accepted the assignment, Lab 6. We're configuring your repository now. This may take a few minutes to complete. Refresh this page to see updates.
    2. After you refresh the page you should see a page with the message: “You're ready to go!”
    3. Note: this will create your own copy of Lab 6 for you to work on, but it's not on your computer yet.

  3. Click on the URL where your assignment repository has been created:
    1. you are now on the GitHub page for your Lab 6 repository

  4. Click on the green button to download your [Code]
    1. a “Clone” dialog box will appear, with the HTTPS tab underlined in red (if not, click on the HTTPS tab to select it)
    2. select the last option labeled “Download ZIP” and save it on your computer
    3. move the Lab 6 zip file from its download location to the cs101 folder that you created during lab last week.
    4. extract the contents of the zip file either by double-clicking on it or control-clicking on it and selecting the appropriate option to extract its contents
    5. navigate into your lab6 folder and confirm you see the lab6.rkt file there

Now you are ready to write some functions using the Design Recipe!


  1. Launch DrRacket and open your lab6.rkt file

  2. Fill in your name where <YOUR NAME> appears in the comments at the top of the program.

  3. Develop the functions for the Exercises as described below.
    • solve each exercise in order
    • follow the steps of the Design Recipe for each function
    • be sure your solution for each exercise includes all appropriate grading artifacts.

  1. Your lab6 starter code contains the data definition, examples, and template function for a pipeline. It also has the function we developed in class: water-running?.

  2. When the temperature drops well below freezing, it is recommended that homeowners turn on a faucet in the house, furthest away from where the water supply enters the house. The water should drip from the faucet, to help prevent the pipes from freezing. One dripping faucet is sufficient, but for this lab, we're going to get a little carried away… :-O

  3. Scroll to the bottom of the lab6.rkt starter code, and add the new function, drip, which turns on all the faucets in the pipeline. Don't forget to follow the Design Recipe, which means writing tests (check-expect's) before you write the function body, and using the template for a pipeline as the starting point for the function body. You should have at least five (5) tests for this function, using all five (5) examples of a pipeline that we used to test the water-running? function.

  4. Implement the count-on function as specified in the starter code, following the Design Recipe.

  5. Implement the modernize function as specified in the starter code, following the Design Recipe.

Get checked off! Be sure Professor Smith or one of your coaches checks you off as having completed the lab before you submit your work electronically, and before you leave. We will look for correct program behavior, as well as well-documented code, including, for each function, a signature, purpose statement, examples, and check-expect statements.

Submitting your work

  • From your browser on the GitHub page for your Lab 6 repository, click on the [Add file] drop-down button and select “Upload files”
  • From your lab6 folder on your desktop, click and drag the lab6.rkt file onto your browser where it says, “Drag files here to add them to your repository”
    • just below the region of the webpage you should see you lab6.rkt file appear; it'll be just above the Commit Changes section of the page.
  • You are now ready to commit changes! Click on the green [Commit changes] button.
  • Your updated lab6.rkt file should now be in your Lab 6 GitHub repository.
    • ask a coach to verify this with you.