Since this problem doesn't involve writing any Scheme functions, use Scheme's multiline comments to comment out your entire file.
For example:
#| Part A (car (cdr x)) = b ... |#
Note: Some implementations of Scheme return the empty list i.e. () for false, but they should all understand #f.
Fill in the blanks in the following transcript: (In other words, fill in the values returned by each of these expressions.)
Work these problems first without using the interpreter. Be sure to check your answers afterwards using Scheme. Please include both your initial guesses and the results of evaluating the expressions in scheme. If they are different, note the reasons why your initial guess was incorrect.
Part A - (15 minutes)
> (define x '(a b ((3) c) d))
> (car (cdr x))
> (caddr x)
> (cdaddr x)
Part B - (15 minutes)
> (define x1 '(a b))
> (define x2 '(a))
> (define x3 (cons x1 x2))
> x1
> (eq? x3 (cons x1 x3))
> (eq? (cdr x3) x2)
> (eq? (car x1) (car x2))
> (cons (cons 'a 'b) (cons 'c '()))
> (cons 1 (cons 2 3))
Instructions on submitting homework is here
Last updated at 3:02 pm on Wednesday, January 29, 2003.