Computer Science 61A - Spring 2001 - Harvey - Midterm 1

Computer Science 61A - Spring 2001 - Harvey - Midterm 1 -...

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

View Full Document Right Arrow Icon
CS61A, Midterm #1, Spring 2001 CS61A, Spring 2001 Midterm #1 Professor Brian Harvey Question 1 (5 points): What will Scheme print in response to the following expressions? If an expression produces an error message, you may just write "error"; you don't have to provide the exact text of the message. If the value of an expression is a procedure, just write "procedure"; you don't have to show the form in which Scheme prints procedures. (butfirst (butlast (se '(this) 'is '(easy) ))) (car ((lambda (lst) (cdr lst)) '((1 2) (3 4)) ) ) (let ((rotate (lambda (a b c) (if (number? a) a (b c 2 3))))) (rotate rotate rotate 1)) (if (equal? '2 2) + -) (map butfirst '((she loves you) (help!) (penny lane))) Question 2 (6 points): The following program takes two arguments: a number and a (1 of 6)1/27/2007 6:29:49 PM
Image of page 1

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

View Full Document Right Arrow Icon
CS61A, Midterm #1, Spring 2001 list of sentences. It returns a sentence containing the n th word (counting from zero) from each of the sentences in the argument list: >(every-nth 2 '((a b c d) (e f g h))) (c g) Fill in the blanks, respecting the data abstraction! (define (every-nth num list-of-sents) (define (nth num sent) (if (= num 0) ( __________ sent) (nth (- num 1) ( __________ sent)))) (if ( __________ list-of-sents) '() ( __________ (nth num ( __________ list-of-sents)) (every-nth num ( __________ list-of-sents)) Question 3 (6 points): (define (enumerate-buzz start end) (if (>start end) '() (cons (buzz start) (2 of 6)1/27/2007 6:29:49 PM
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