A5 — Introduction to lists and review
Practice using lists.
Due Sep 30, 2026
Estimated time to complete (just the assignment, excluding the prep materials): 40–80 min.
Prep materials: Week 5: Introduction to lists and review.
What to do
Create a file a5.arr and add all your code there. Remember to test that the file runs before submitting; double check the context and names. Submit the file to Assignment 5 Submission on Brightspace.
Define the name
rect-perim-1to be the perimeter of a rectangle with sides 4 and 7.Define a check-block named
check-rect-perim-1to check thatrect-perim-1is correct.Define a function named
signthat takes a number and returns 0.Define a check-block named
check-signto check that thesignfunction returns 1 if the number is positive, -1 if the number is negative, and 0 if the number is zero. Do these tests fail? Do any of them pass?Change the implementation of
signto return 1 if the number is positive, -1 if the number is negative, and 0 if the number is zero. Do the tests incheck-signpass now?Define a function named
gen-shape(along with a check-block namedcheck-gen-shape) that takes a string with the name of the shape, a color string, and a size number, and returns a corresponding image with the solid filling.- The shape can be one of “circle”, “square”, “triangle”, and the shape description is case-insensitive (meaning, both “CirCLE” and “circle” are valid).
- If the given shape is anything else, the function should throw an error.
Note: to check that a function call throws an error, you can useraises ""in your check-block, e.g.,5 / 0 raises "".
Define the name
list-sizesto be a list of numbers 10, 15, 20, 25, 30. Hint.Define the name
list-el-firstto be the first element oflist-sizes.Define the name
list-sqrtsto be a list of the square roots of the elements oflist-sizes. Do not build the list manually. Hint.Define a check-block named
check-list-sqrtsto check that the length oflist-sqrtsis the same as the length oflist-sizes, and that at least one element oflist-sqrtshas the correct value.Define the name
list-squaresto be a list of solid blue squares with the side lengths given by the elements oflist-sizes. Do not build the list manually.Define the name
list-shape-namesto be a list of"circle", "triangle", "square", "triangle", "circle".Define a function named
gen-shapes(along with a check-block namedcheck-gen-shapes) that takes a list of shape names and a color string, and returns a list of corresponding images with the solid filling, where the size parameter for each shape is 16.Define the name
list-shapesto be the result of callinggen-shapeswithlist-shape-namesand"green".Recover the
gamestable from Assignment 3 and define the namelist-game-namesto be a list of the names of the games in the table.
Grading
Auto-graded for correctness, with named check-blocks auto-graded for coverage.