#lang racket (require csc151) (require rackunit) (require rackunit/text-ui) ;;; File: ;;; 000000.rkt ;;; Authors: ;;; The student currently referred to as 000000 ;;; Titus Klinge ;;; Samuel A. Rebelsky ;;; Contents: ;;; Code and solutions for Exam 1 2017F ;;; Citations: ;;; ; +---------+-------------------------------------------------------- ; | Grading | ; +---------+ ; This section is for the grader's use. ; Problem 1: ; Problem 2: ; Problem 3: ; Problem 4: ; Problem 5: ; Problem 6: ; ---- ; Total: ; Scaled: ; Errors: ; Times: ; : ; : ; : ; ---- ; Total: ; +----------+------------------------------------------------------- ; | Prologue | ; +----------+ ; Time Log: ; Date Start Finish Elapsed Activity ; +-----------+------------------------------------------------------ ; | Problem 1 | ; +-----------+ ; Time Log: ; Date Start Finish Elapsed Activity ; Time Spent: ; Citations: ; Solution: ;;; Procedure: ;;; add3 ;;; Parameters: ;;; ;;; Purpose: ;;; ;;; Produces: ;;; ;;; Preconditions: ;;; ;;; Postconditions: ;;; (define add3b 'STUB) (define add3c 'STUB) (define add3d 'STUB) ; Examples/Tests: ; +-----------+------------------------------------------------------ ; | Problem 2 | ; +-----------+ ; Time Log: ; Date Start Finish Elapsed Activity ; Time Spent: ; Citations: ; Solution: ;;; Procedure: ;;; sublist ;;; Parameters: ;;; ;;; Purpose: ;;; ;;; Produces: ;;; ;;; Preconditions: ;;; ;;; Postconditions: ;;; (define sublist (lambda (lst start finish) lst)) ; Examples/Tests: ; +-----------+------------------------------------------------------ ; | Problem 3 | ; +-----------+ ; Time Log: ; Date Start Finish Elapsed Activity ; Time Spent: ; Citations: ; Solution: ;;; Procedure: ;;; ;;; Parameters: ;;; ;;; Purpose: ;;; ;;; Produces: ;;; ;;; Preconditions: ;;; ;;; Postconditions: ;;; (define f (lambda (a b c) (list->string (map1 (o (section string-ref a <>) (section + b <>)) (iota (- c b)))))) ; Examples/Tests: ; +-----------+------------------------------------------------------ ; | Problem 4 | ; +-----------+ ; Time Log: ; Date Start Finish Elapsed Activity ; Time Spent: ; Citations: ; Solution: ; a. ;;; Procedure: ;;; remove-odds ;;; Parameters: ;;; ;;; Purpose: ;;; ;;; Produces: ;;; ;;; Preconditions: ;;; ;;; Postconditions: ;;; ; b. (define tests-remove-odds (test-suite "Tests of the remove-odds procedure" (test-case "Empty lists" (check-equal? (remove-odds (list)) (list))) (test-case "Non-empty lists with no odd numbers" (check-equal? (sort (remove-odds (list 2 10 8 6 4)) <) (list 2 4 6 8 10) "A few small even integers")))) ; +-----------+------------------------------------------------------ ; | Problem 5 | ; +-----------+ ; Time Log: ; Date Start Finish Elapsed Activity ; Time Spent: ; Citations: ; Solution: (define remove-odds (lambda (lst) lst)) ; STUB ; +-----------+------------------------------------------------------ ; | Problem 6 | ; +-----------+ ; Time Log: ; Date Start Finish Elapsed Activity ; Time Spent: ; Citations: ; Supplied code (define teaching-fall-2017 (list (list "Curtsinger" "Charlie" "Professor" (list "TUT-100" "CSC-211")) (list "Klinge" "Titus" "Professor" (list "CSC-151" "CSC-341" "CSC-395")) (list "Osera" "Peter-Michael" "Professor" (list "TUT-100" "CSC-207" "MAT-208")) (list "Rebelsky" "Samuel" "Campus Curmudgeon" (list "CSC-151" "CSC-301" "CSC-321" "CSC-322")) (list "Vostinar" "Anya" "Professor" (list "CSC-207" "CSC-301")) (list "Weinman" "Jerod" "Department Chair" (list "CSC-161")))) ; Solution: ;;; Procedure: ;;; describe-teaching ;;; Parameters: ;;; person, a list ;;; Purpose: ;;; Generate a string that describes the teaching responsibilities ;;; of a faculty member. ;;; Produces: ;;; description, a string ;;; Preconditions: ;;; * list has the form ;;; (surname:string forename:string title:string courses:list-of-strings) ;;; * courses is nonempty ;;; Postconditions: ;;; description is a string of the form "TITLE FORE SUR is teaching COURSE" (define describe-teaching (lambda (person) "STUB")) ; Examples/Tests: ;(check-equal? ; (describe-teaching (list "Last" "First" "Title" (list "A"))) ; "Title First Last is teaching A") ;(check-equal? ; (describe-teaching (list "Last" "First" "Title" (list "A" "B"))) ; "Title First Last is teaching A and B") ;(check-equal? ; (describe-teaching (list "Last" "First" "Title" (list "A" "B" "C"))) ; "Title First Last is teaching A and B and C") ; (map describe-teaching teaching-fall-2017)