CS61A_fa03_mt2

CS61A_fa03_mt2 - CS61A Fall 2003 Midterm 2(Clancy/Hilfinger...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS61A Fall 2003 Midterm 2, Clancy/Hilfinger Problem 1 (4 points, 5 minutes) Part a Fill in the blanks below to complete the next-higher procedure. Given a grade A, B, C, D, or F, next-higher returns the next higher grade; the next higher grade for A is A. (define (next-higher grade) (cadr (assoc grade ________________________________________________________________________________) ) ) Part b A grading policy is a procedure that takes as argument a list of scores and returns a letter grade. Define a procedure named generous that, given a grading policy as an argument, returns a grading policy that awards a grade one higher than the argument policy would give. Use the next-higher procedure from part a. Problem 2 (4 points, 7 minutes) Consider the following procedure. (define (exam a) (let ((b 9)) (lambda (c) (let ((d 11)) (set! a (+ a 1)) (set! b (+ b 2)) (set! c (+ c 3)) (set! d (+ d 4)) (list a b c d) ) ) ) ) Fill in the blank with the output that stk would produce. STk> (define f (exam 7)) f CS61A Fall 2003 Midterm 2 (Clancy/Hilfinger) 1
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
STk> (f 5) (8 11 8 15) STk> (f 1) ____________________ Problem 3 (6 points, 7 minutes) Suppose the second and third arguments to the call to lookup-variable-value in eval-1 are accidentally
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern