Skip to main content

Homework 8 — University Student Records: Lists (Recursion)

Skills: 5

Due

Thursday, October 30, 2025 at 6PM (Oakland) or 9PM (Boston)


Introduction

You're working on a student information system for a university. The system uses lists to track various data about students, including their grades, course enrollments, and academic records. Throughout this assignment, you'll use recursive functions to process and analyze this student data.

DO NOT USE for each LOOPS!

Assume grades are represented as numbers (0-100), and student names are represented as strings.

Problem 1

Design a function count-until-failing that takes a list of grades and counts how many grades appear BEFORE the first failing grade (< 60). If there are no failing grades, return the total count of all grades.

Problem 2

Design a function valid-grade-sum that takes a list of grades and returns the sum of all grades, but if any grade is invalid (negative or over 100), return -1 immediately without processing the rest.

Problem 3

Design a function grades-before-target that takes a list of grades and a target grade, and returns a list of all grades that appear BEFORE the first occurrence of the target grade. If the target doesn't exist, return all grades.

Problem 4

Design a function nested-sum that takes a list that may contain both numbers or other lists of numbers or lists, and returns the sum of all numbers at any level.

For example: nested-sum([list: 1, [list: 2, 3], 4, [list: 5, [list: 2, 1]]]) should return 18.