Coding Challenge 6: Recursion

Assigned
Monday, 2 March 2026
Summary
In this coding challenge we solve problems using recursion.
Collaboration
Normal collaboration policies for coding challenges apply to this assignment. See the syllabus for specifics.

Instructions

We are providing you with starter code, CC6-template.scm. You should download this file and upload the given code to a new .scm file named LASTNAME-reucrsion.scm where you replace LASTNAME with your last name.

You are required to document every procedure that you write using the documentation style of our course. Tests are optional, but likely helpful in determining if your code is working as desired and additionally required for an E grade.

At the top of your file, make sure to include your name, and any acknowledgements according to our collaboration policy. Now is a great time to review those collaboration policies.

Problem 1: Remove val

Write a recursive procedure (remove-all val lst) that removes all copies of val from lst.

> (remove-all "a" (list "b" "a" "d" "a" "c"))
("b" "d" "c")
> (remove-all 7 (list 7 7 7 4 3 7 2))
(4 3 2)

The returned list should be in the same order as the elements appear in the original list.

Problem 2: Remove duplicates

Write a recursive procedure (remove-duplicates lst), that takes a list as input and returns the same list, but with the duplicates removed. Elements that remain should be in the same order as their first appearance in the original list.

> (remove-duplicates (list 4 2 1 5 2 4 6 1 23 27 6 1 1 1 2))
(4 2 1 5 6 23 27)

You will likely find your procedure from part 1 helpful here.

Problem 3: Joining sorted lists

Write a recursive procedure, (merge-sorted-lists lst1 lst2), that takes as input two lists of real numbers that are ordered from smallest to largest and returns the combination of those two lists, still in sorted order.

You may not use sort in your solution, instead you must use recursion.

> (merge-sorted-lists (list 1 5 6 7 22) (list 0 2 3 4 7 18 19))
(0 1 2 3 4 5 6 7 7 18 19 22)
> (merge-sorted-lists (list 1 3 5 7) (list 2 3 4 5 6))
(1 2 3 3 4 5 5 6 7)

Submission guidelines

Submit your .scm file to Gradescope, using the name according to the top of these instructions.

Grading rubric

In grading your submission, we will look for the following at each level. Note that if a criteria does not pass a lower level, we will likely not check for criteria at the higher levels. We may also identify other characteristics that move your work between levels.

You should read through the rubric and verify that your submission meets the rubric.

Redo or above

Submissions that lack any of these characteristics will get an N.

[] Includes the specified file (correctly named).
[] Includes an appropriate header on the file that indicates the course, author, acknowledgements, etc.
[] Acknowledges appropriately.
[] Code runs in scamper.

Meets expectations or above

Submissions that lack any of these characteristics but have all of the prior characteristics will get an R.

[] Code is well-formatted with appropriate names and indentation.
[] Code submission is organized with comments to indicate the start of new problems.
[] All Gradescope tests pass for Problem 1.
[] All Gradescope tests pass for Problem 2. 
[] All Gradescope tests pass for Problem 3. 
[] All problems use recursion to solve the problems 
[] Documentation in the 151 style is included for all code, and contains correct information.

Exemplary / Exceeds expectations

Submissions that lack any of these characteristics but have all of the prior characteristics will get an M.

[] All code is exceptionally organized and easy to read, through the use of comments (to explain the purpose of different pieces of the code), decomposition, and highly intuitive naming choices.
[] All solutions do not make calls to built-in recursive procedures such as `filter`, `map`, `append`, `tally-all`, etc.
[] All three problems include a wide variety of tests which cover edge cases beyond those presented in the assignment.