Homework #5


Since this problem doesn't involve writing any Scheme functions, use Scheme's multiline comments to comment out your file.

This problem requires Lecture 4.

Part A
Consider the following definitions without entering them into an interpreter just yet.

(define f
  (lambda (x)
     (lambda (y)
       (y x))))

(define g (f (list 1 2 3 4 5)))

How would you describe f? What would you expect to be passed to it?

How would you describe g? What would you expect to be passed to it?

What would (g display) return? How about (g length)? (g 5)?

Verify your answers by typing this in and playing with the functions f and g.

Please don't cheat and plug the code into the interpreter since you'll get a great deal of understanding out of trying it out by yourself.

Part B
Consider two or three languages you know or for which you can find documentation. What restrictions, if any, are imposed on procedures that keep them from being first class? Is it possible to create anonymous procedures (ones without names bound to them)?

I consider questions like this to be at the heart of this course. You should ask yourself these kinds of questions as you read and study. Questions like this one will appear on the exams.


You must log in first before submitting homework assignments.

Instructions on submitting homework is here


Last updated at 9:16 pm on Friday, September 03, 2004.