CS212 Exams
Spring 1999 - Prelim 1

Evaluation of Scheme Expressions


Determine the value (if any) to which the following Scheme expressions evaluate. If evaluating the expressions leads to an error for some reason, indicate what the problem is. You need not show the steps in the evaluation, but if you are unsure, explain how you got your value for partial credit.

  1. (define f (lambda (x) (f (+ 1 x))))
      (f 3)
  2. ((lambda (f) (lambda (x) (+ 1 (f x)))) head)
  3. (if #t 1 (tail empty))
  4. ((lambda (e1 e2 e3) (if e1 e2 e3) #t 1 (tail empty))
  5. (define (foo x) (+ x 1))
    (define (bar x)
      (let ((foo (lambda (x) (bar (- x 1)))))
        (if (= x 0) #t (foo x))))
    (bar 3)

Solution

Return to CS 212 Prelim 1 - Spring 1999