COM1340 - Winter 2003 Assignment 1 Due: January 15, 2003 |
Set DrScheme to use the PLT | Graphical language level.
Exercises 0, 1 and 2 are for your instruction; you are not required
to turn in your work. For Exercises 3 and 4, print out the contents
of the interactions window. On your printout, legibly write your name and
``COM1340 -- Assignment 1.''
0.) In DrScheme's Help Desk, look up the primitive set!. After you've
understood what it does, say the following words aloud: ``I will not use
set! in any assignment for my Recursive Thinking class, nor will
I use set! in any exam for that class.'' Repeat the lookup and
oath for the primitive length, although you need not say the oath
quite as loudly in this case.
1.) Enter the following expressions in the DrScheme definitions (upper) window:
(define x (list 'x 'y 'z)) (define y (list 'a 'b 'c))
2.) In the interactions (lower) window, enter the following expressions, hitting
RETURN after each:
x y (cons x y) (cons y x) (car (cdr x)) (cons x x) (cons y y) (car (cons x y)) (null? (cdr x)) (null? (cdr (cdr x))) (null? (cdr (cdr (cdr x)))) (eq? (car x) (car y)) (eq? (car x) 'a) (eq? (car x) 'b) (eq? (car x) (car (cons x x))) (eq? (car x) (car (car (cons x x))))
Convince yourself that each evaluation is correct.