CS 3520 Homework 1   - Due August 28

This homework is due August 28, 11:59 PM. Implement all of the requested functions in a single file, hw1.scm, and submit it with handin for hw1, e.g.:
   handin cs3520 hw1 hw1.scm

In the exercises below, underlined Scheme text corresponds to displayed values, and other Scheme text corresponds to evaluable expressions. Italics indicate meta-variables.

Exercise 1.1, Scheme warm-up

Implement the following functions (to be graded purely on input-output correctness):

Exercise 1.2, Expressions vs. displayed values

Which of the following equivalences are true?
  1. 1 = 1
  2. 'hello = 'hello
  3. 'hello = hello
  4. ''hello = 'hello
  5. '(1 2 . 3) = (1 2 . 3)
  6. (cons 1 2) = (1 . 2)
  7. (list 1 2) = (1 . 2)
  8. (cons 1 2) = (1 2)
  9. (list 1 2) = (1 2)
  10. (list 'lambda '() 10) = (lambda () 10)
  11. (cons 'lambda (cons '() 10)) = (lambda () 10)
  12. (cons 'lambda (cons '() (cons 10 '()))) = (lambda () 10)
Express your answer as a function answer-for-1.2 that takes no arguments and returns a list of twelve booleans. For example, if the first five equivalences are true and the last seven are false, your function should produce (#t #t #t #t #t #f #f #f #f #f #f #f).

Exercise 1.3, Scheme evaluation

On paper (not handed in), work out all the steps showing how the expression
(((lambda (x) (lambda (y) (- x y))) 2) 1)
reduces to 1.

Then, write a function step (to be handed in) that takes a number n from 0 to 3 and returns a Scheme value representing the nth step of the evaluation of the above expression. Examples: Of course, step is not an evaluator in any interesting sense; it merely reports the constant expressions that you worked out on paper.


Last update: Thursday, September 21st, 2000
mflatt@cs.utah.edu