homework1

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

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

View Full Document Right Arrow Icon
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 definition: (define x ’(define (fac n) (if (= n 0) 1 ( * n (fac (- n 1)))))) (This defines 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online