CIS 352   —   SPRING 2008

Homework 2


Coverage

This homework covers material in Chapter 2 (through Section 2.8) of The Scheme Programming Language (Dybvig), as well as Chapter 1 of Essentials of Programming Languages (EOPL).

Logistics

This homework is officially due in the bin in CST 3-212 by noon on Friday, February 1.

You may work singly or in pairs on this assignment.

What to Turn in:

EXERCISES

  1. (10 points) EOPL, Exercise 1.15(2)

  2. (10 points) EOPL, Exercise 1.15(3)

  3. (10 points) EOPL, Exercise 1.15(4)

  4. (15 points) EOPL, Exercise 1.15(6)

  5. (15 points) EOPL, Exercise 1.15(8)

  6. (15 points) EOPL, Exercise 1.16(2)

  7. (15 points) EOPL, Exercise 1.16(4)

  8. (15 points) Write a Scheme procedure compose-all that takes an arbitrary number of 1-argument procedures and returns their composition. For example, compose-all should have the following behavior:

    > (define my-caddr (compose-all car cdr cdr)) 
    > (my-caddr '(a b c d e)) 
    c 
    
    > (define plus1 (lambda (x) (+ x 1))) 
    > (define times10 (lambda (y) (* y 10))) 
    > ((compose-all times10 times10 plus1 plus1) 3) 
    500
    
    > ((compose-all) 17) 
    17 
    Note: The result of composing 0 procedures is the identity procedure (i.e., the procedure that returns the value of its argument).

Back to the CIS 352 Homepage
Jim Royer /