The main purpose of this lab is to have:
More practice with lists: lists of strings and lists of structures (posn's)
More practice with sorting
More practice designing programs with wish lists (helper functions)
More practice documenting functions with signature, purpose statement, examples, and check-expects
How to get started
-
Login to Github and you will be prompted to accept this assignment
After you click on the [Accept this assignment] button, you will see a new page display in your browser with the message:
You accepted the assignment, Lab 5. We're configuring your repository now. This may take a few minutes to complete. Refresh this page to see updates.
After you refresh the page you should see a page with the message: “You're ready to go!”
Note: this will create your own copy of Lab 5 for you to work on, but it's not on your computer yet.
-
you are now on the GitHub page for your Lab 5 repository
Click on the green button to download your [Code]
a “Clone” dialog box will appear, with the HTTPS tab underlined in red (if not, click on the HTTPS tab to select it)
select the last option labeled “Download ZIP” and save it on your computer
move the Lab 5 zip file from its download location to the cs101
folder that you created during lab last week.
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
navigate into your lab5
folder and confirm you see the lab5.rkt
file there
Now you are ready to write some functions using the Design Recipe!
Instructions
Launch DrRacket and open your lab5.rkt
file
Fill in your name where <YOUR NAME> appears in the comments at the top of the program.
Develop the functions for the Exercises as described below.
solve each exercise in order
follow the steps of the Design Recipe for each function (not all exercises require designing a function).
be sure your solution for each exercise includes all appropriate grading artifacts.
Exercises
Design a function that sorts a list of strings in ascending order. It will be a lot like the function we designed in class this week that sorts a list of numbers. Be sure to follow the Design Recipe, and include hand-in artifacts:
Data Definition for a list-of-string
you will find it useful to define at least two lists of strings–one unsorted, one sorted in ascending order
Template for a function that consumes a list-of-string
Signature/Purpose Statement/Header
Examples in the form of check-expects
Only when all of the above is complete should you fill in the function body
As was the case with the function that sorted a list of numbers, you will need a helper function that inserts a string into a sorted list of strings.
Add it to your wish list, and develop it separately, using the Design Recipe
For this helper function, you will find the built-in string comparison function
string<=?
to be helpful
Design a function that sorts a list of posns in ascending order by the posns' x value. It, too, will be a lot like the function we designed in class this week that sorts a list of numbers. Be sure to follow the Design Recipe, and include hand-in artifacts:
Data Definition for a list-of-posn
you will find it useful to define at least two lists of posns–one unsorted, one sorted in ascending order by the posns' x value
Template for a function that consumes a list-of-posn
Signature/Purpose Statement/Header
Examples in the form of check-expects
Only when all of the above is complete should you fill in the function body
As was the case with the function that sorted a list of numbers, you will need a helper function that inserts a posn into a sorted list of posns.
Add it to your wish list, and develop it separately, using the Design Recipe
For this helper function, you will need to use an additional helper function. Call it
posn-x<=?
, and add it to your wish list
Finally, use the Design Recipe to design the helper function that compares two posns by their x value, and produces #true if the first posn's x value is less than or equal to the second posn's x value.
The signature for this function is:
posn-x<=? : posn posn -> bool
Your function should not contain a cond
expression or an if
expression–only a boolean expression is required.
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 5 repository, click on the [Add file] drop-down button and select “Upload files”
From your lab5 folder on your desktop, click and drag the lab5.rkt
file onto your browser where it says, “Drag files here to add them to your repository”
You are now ready to commit changes! Click on the green [Commit changes] button.
Your updated lab5.rkt
file should now be in your Lab 5 GitHub repository.