Due: Wednesday, July 5 at 6pm (submit through Canvas)
To practice writing programs over tables
To have you apply basic tables to a problem of your own interest
Collaboration Policy: You may work with others on the Ice Cream problems. Your work on "Design Your Own Table" must be entirely your own. You’ll submit each set of exercises in a separate file. Include a collaboration statement in each one.
Use the filename icecream.arr for this part.
A local ice cream store stores information about its current flavors in a Google Sheet. It wants to use data from the sheet to generate the menu for its new digital menu board. Your job is to write the programs they need to generate content for the menu board.
Here’s the link to the Google sheet. Create a Pyret file for this assignment, and load this sheet as your initial table. We’ll refer to this as the flavors table in describing subsequent problems.
Loading a Table from Google Sheets: the following lines show you how to load the above table into Pyret:
# the long string below is the last part of the URL to the sheet
flavors-sheet = load-spreadsheet("1drj1kiC3VVCe17wrrTpNUn0DSx9R0mhdNkan7znOdcE")
flavors = load-table: name, core, add-in, base, style
source: flavors-sheet.sheet-by-name("flavors", true)
The "flavors" in the sheet-by-name line names the sheet within the Google spreadsheet. It is coincidence that this is also the name given to the table in the Pyret dictionary.
Define a table named has-chocolate that contains the rows from the flavors table in which either the "Core Flavor" or "Add In" columns contain the string "chocolate". Pyret’s string-contains function is useful here.
Did you get the answer that you expected? Did you remember to write down the answer that you expected before writing the has-chocolate program? No need to write down your answer—
just think about it.
Clearly, the ice cream folks are too busy scooping to keep their capitalization consistent. Two possible solutions here are to modify your has-chocolate program to look for either "chocolate" or "Chocolate", or you could transform the table you read in to convert all the core flavors to lowercase as soon as you load the table. What are the advantages and disadvantages of each approach? Put your answer in a block comment in your Pyret file.
Define a table named clean-flavors that puts the strings in the "Core Flavor" and "Add In" columns all in lowercase. Look in Pyret’s strings documentation to find a function that will help you do this.
The ice cream store frequently gets visitors with dietary restrictions. They want to list flavors that are either vegan or nut-free in separate sections of the menu. Define a table named nut-free-vegan-menu that contains two new columns of booleans:
The first indicates whether the item is vegan (which means it has "almond milk" or "coconut milk" as its base and does not use "marshmallows" as its add-in)
The second new column indicates whether the item is free of nuts (which means it does not use "almond milk" as its base or "peanuts" as its add-in).
In order to generate the menu for the digital display board, the ice cream shop needs not just the names of the flavors, but also a description of each flavor that indicates the core flavor, add-in, and style of the flavor. Here are examples of the descriptions they want to see:
"black raspberry ice cream with chocolate chips" (for either hard or soft serve ice cream)
"simple strawberry ice cream" (for an item with no add-in)
"mango frozen yogurt with papaya" (for frozen yogurt)
Define a table called descriptions that includes a new column with the descriptions of each item, following these examples.
It’s time to generate the flavor menu! The shop needs the menu sorted first by style (soft, then hard, then frozen yogurt), then sorted alphabetically by the flavor name within each of those categories. Sort the menu, then define a table named menu that contains just the flavor names and descriptions in this sorted order.
The ice cream shop has a new employee who will be in charge of maintaining the flavor spreadsheet. The programs you wrote for this assignment make certain assumptions about the data in the spreadsheet (how things are worded, for example). You want to give the new employee instructions on how to fill in the spreadsheet and what kinds of changes you need to know about so your programs continue to work as intended.
Provide a bullet list in a block comment as your answer. Each bullet item should contain a brief/one-sentence summary of the issue and a concrete example of a cell content that would cause a problem (indicate which column the cell is in).
We are NOT asking you to modify your code to work around these issues. This question simply checks whether you are able to think about what the issues might be. We have more to learn before we can begin to address potential issues here.
Use any filename you wish for this part, but put it in a separate file from the ice cream problems.
It’s your turn to design a table and some programs using either a dataset or problem context that interests you. You can choose any example you like, as long as you meet the following requirements:
Your table needs at least three columns to start, and at least four columns by the end (this doesn’t mean you have to add a column—
you could start with a larger table).
Use at least two datatypes in your columns (i.e., at least one number column and one boolean column, or one string column and one number column, etc).
Provide three programs that perform sensical/semi-realistic computations on your table. Across your programs, you should use each of the the select, order, transform, and sieve operators at least once. You may use extend if you wish.
At least two of your programs should use at least two operators apiece.
These aside, feel free to experiment and have fun! You can create the table manually, or load from a Google sheet (up to you). You can use a real dataset or make one up. If you have no idea how to proceed, feel free to ask for help.
We will grade your work both on the correctness of output you produce and on the structure of your code. We grade correctness by computer, and style by human inspection. For structure on this assignment, we want to see you using names, comments, and newlines to make your code readable to others.
Remember to include the collaboration statement in each file.
Two files, icecream.arr and whatever you called your other file.