CS61A_fa03_mt2

CS61A_fa03_mt2 - CS61A Fall 2003 Midterm 2...

Info iconThis 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
STk> (f 5) (8 11 8 15) STk> (f 1) ____________________ Problem 3 (6 points, 7 minutes)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/23/2010 for the course CS 61A taught by Professor Harvey during the Fall '08 term at Berkeley.

Page1 / 5

CS61A_fa03_mt2 - CS61A Fall 2003 Midterm 2...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online