; This file contains part of the program that was used to ; compute the final grades in CS U215/216, Summer 1 2005. ; ; This program is written in Scheme, which is one of the ; languages in the Lisp family. ; Numerical nonsense. (define (num n) (if (number? n) n 0)) (define (round1 x) (/ (round (* 10.0 x)) 10.0)) ; Given a list of raw scores and possible scores, ; returns the scaled score out of 100. (define (scaled-score scores possibles) (let* ((score (apply + (map num scores))) (possible (apply + possibles))) (* 100.0 (/ score possible)))) ; Curve by dropping the most damaging. ; FIXME: Relies on the linearity of scaled-score. (define (curve-by-dropping1 scores possibles) (apply max (map (lambda (s p) (scaled-score (cons (- s) scores) (cons (- p) possibles))) scores possibles))) ; Curving by dropping the low assignment. (define (curve-homework1 scores) (curve-by-dropping1 scores possible-hw)) ; Curving by dropping the low quiz. (define (curve-quizzes1 scores) (curve-by-dropping1 scores possible-qz)) ; No curve on homework. (define (curve-homework0 scores) (scaled-score scores possible-hw)) ; No curve on quizzes. (define (curve-quizzes0 scores) (scaled-score scores possible-qz)) ; Drop whichever score, exam or homework, that gives the highest ; overall grade. (define (rawscore x) (let* ((hw-scores (map (lambda (f) (num (f x))) (list hw0 hw1 hw2 hw3 hw4 hw5 hw6))) (qz-scores (map (lambda (f) (num (f x))) (list qz1 qz2 qz3 qz4 qz5 qz6))) (hw0 (curve-homework0 hw-scores)) (hw1 (curve-homework1 hw-scores)) (qz0 (curve-quizzes0 qz-scores)) (qz1 (curve-quizzes1 qz-scores))) (max (round1 (+ (* .60 qz0) (* .40 hw1))) (round1 (+ (* .60 qz1) (* .40 hw0)))))) (define (lettergrade n) (cond ((>= n 93.0) "A ") ((>= n 90.0) "A-") ((>= n 87.0) "B+") ((>= n 83.0) "B ") ((>= n 80.0) "B-") ((>= n 77.0) "C+") ((>= n 73.0) "C ") ((>= n 70.0) "C-") ((>= n 67.0) "D+") ((>= n 63.0) "D ") ((>= n 60.0) "D-") (else "F ")))