homework1

# homework1 - Homework 1 CSC 4101 Fall 2011 Due 8 September...

This preview shows pages 1–2. Sign up to view the full content.

CSC 4101, Fall 2011 Due: 8 September 2011 1. (10 pts) Draw binary tree diagrams for each of the following Scheme expressions: (a) ’(a (b c) d e) (b) ’((((a b) (c d)) e)) (c) ’(a (b (c (d (e f))) ())) (d) ’(((()) ((())))) (e) ’(((a b) c) d (((e f) g))) 2. (10 pts) Show the result of evaluating each of the following Scheme expressions: (a) (cdr ’((a (b)) (c))) (b) (cons ’(a) ’((b) (c))) (c) (car (car (cdr ’(a ((b (c))))))) (d) (quote (car ’(a ((b) c)))) (e) (car (quote (cons ’a ’((b) c)))) 3. (10 pts) Given the following Scheme deﬁnition: (define x ’(define (fac n) (if (= n 0) 1 ( * n (fac (- n 1)))))) (This deﬁnes not the factorial function fac , but the variable x .) Write Scheme expressions in terms of x that would have the effect of extracting the following expres- sions: (a) (fac n) (b) 0 (c) (- n 1) (d) The second occurrence of fac . (e) The last occurrence of n . E.g., the expression

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

homework1 - Homework 1 CSC 4101 Fall 2011 Due 8 September...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online