A6 — Processing and decomposing lists
Practice processing lists using built-in functions; learn to decompose lists and process them yourself, without built-ins.
Due Oct 7, 2026
Estimated time to complete (just the assignment, excluding the prep materials): 1.5–2 hours.
Prep materials: Week 6: Lists continued.
What to do
Create a file a6.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 6 Submission on Brightspace.
For this assignment, you will work again with the games table from Assignment 3. Do not compute any answers manually or type out list literals that you could extract from the table.
Part 1: Built-in list functions
For this part, you need to use only the built-in list functions from DCIC Section 5.1, and you may not decompose any lists yourself.
Define the name
list-game-titlesto be the list of titles of the games in thegames. Hint.Define
list-game-short-titlesto be the list of titles of the games that have at most 10 characters. Hint.Define
list-game-ratingsto be the list of ratings of all games ingames.Define
max-game-ratingto be the highest rating of a game.Define
list-game-ratings-roundedto be the list of ratings rounded to the nearest integer, and define a check-block namedcheck-list-game-ratings-roundedwith at least two distinct test cases. Hint 1. Hint 2.Define a function
count-of(along with a check-block namedcheck-count-of) that takes a list and a value, and returns how many times the value occurs in the list. For example,count-of([list: "a", "b", "a"], "a")is2. Use the following function signature:fun count-of<A>(l :: List<A>, v :: A) -> NumNonNegative:Click here for a hint
You will need to use multiple built-in list functions, and you will need a lambda (anonymous) function to deal with the value comparison.
Part 2: Calculator
Recover the implementation of calc from Assignment 4 and add it to your a6.arr file. (You can also use calc from the solution published on Discord.)
Define a function calc-string (along with a check-block named check-calc-string) that takes a string of the form "number operator number" and returns the result of the calculation. Hint.
For example,
calc-string("3 - 7")is-4, andcalc-string("11 % 2")is1.If the string is not in the correct format,
calc-stringshould throw an error.
Part 3: Decomposing lists
For this part, do not use any built-in list functions except for link, empty, .first, and .rest.
Define
list-linkedto be the list of numbers 10, 15, 20 built using onlylinkandempty, and define a check-block namedcheck-list-linkedthat checks thatlist-linkedis equal to[list: 10, 15, 20]. Hint.Define
third-linkedto be the third element oflist-linked, using only.firstand.rest.Define
rest-linkedto be the list of the last two elements oflist-linked.Define function
round-all(along with a check-block namedcheck-round-all) that takes a list of numbers and returns a list of the numbers rounded to the nearest integer. For example,round-all([list: 3.2, -4.7, 5.55])is[list: 3, -5, 6]. Check that the result of callinground-allonlist-game-ratingsis equal tolist-game-ratings-rounded. Hint.Define a function
short-titles(along with a check-block namedcheck-short-titles) that takes a list of strings and returns the strings from the list that have at most 10 characters. Check that the result of callingshort-titlesonlist-game-titlesis equal tolist-game-short-titles.
Part 4: Too many circles
- Create a blue solid circle with a radius 5.
- Create a blue solid circle with a radius 10.
- Create a blue solid circle with a radius 15.
- … are you tired yet?
- The whole task is to create blue solid circles with radii 5, 10, 15, 20, 25, 30, 35, 40, 45, 50. How can we do it without writing out each circle manually?
Grading
Auto-graded for correctness and some aspects of style (in particular, handling of erroneous inputs), with named check-blocks auto-graded for coverage.