;; g is a nat between 0 and 100, and ;; gl is a gradelist. (define-struct course-result (title grades)) ;; A course-result is a structure (make-course-result t g), where ;; t is a string (title of course), ;; g is a gradelist (grades of all students in the course) ;; most-As: (listof course-result) -> (listof title) ;; purpose: the purpose of most-As is is to determine ;; which courses from the list passed into it (courses) ;; and produces a list of strings indicating which courses ;; had the highest number of As ;; Examples: ;;(check-expect (most-As (list (make-course-grade "CS116" '(0 66 99 77)) ;; (make-course-grade "CS126" '(0 66 19 27)) ;; (make-course-grade "CS136" '(0 66 59 77)))) ;; (list "CS116")) ;; Definition: (define (most-As courses) (local [ ;; determines whether it's above 80 (define (rep? n) (cond [(>= n 80) #t] [else #f])) ;; leaves only a list of above 80 ;;passing in a list of structures (which have lists within them) (define (extract-As courses) (filter rep? (course-result-grades courses))) ;;maps the above function - separated for readability (define (app-e course) (map length (map extract-As course))) ;;extract-courses (define (extract-course courses) (map course-result-title courses)) (define gradelist (app-e courses)) (define name (extract-course courses))] 'something-should-be-put-here)) ;; Tests: ;; If my code actually worked, these tests would pass: ;;(check-expect (most-As empty) empty) ;;(check-expect (most-As ;; (list (make-course-result "math177" '(0 38)))) 0) ;;(check-expect (most-As ;; (list (make-course-result "JAP101" '(44 99)) ;; (make-course-result "NEOPETS388" '(86 34 90 77)) ;; (make-course-result "math9000" '(90 55 22 33 44 55 11)))) ;; (list "NEOPETS388")) ;;(check-expect (most-As (list (make-course-grade "CS116" '(0 66 99 77)) ;; (make-course-grade "CS126" '(0 66 99 77)) ;; (make-course-grade "CS136" '(0 66 99 77)))) ;; (list "CS116" "CS126" "CS136"))