This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 6, 8, 10, 6, 8 2. Write a function an-atom-of that dispenses the atomic elements of a deep list (not including empty lists). For example, > (an-atom-of ((a) ((b (c))))) ==> a > try-again ==> b (define (an-atom-of ls) (cond ((null? ls) (amb)) ((atom? ls) ls) (else (amb (an-atom-of (car ls)) (an-atom-of (cdr ls)))))) Chung Wu; CS61A, Spring 2004 1 3. Use an-atom-of to write deep-member? . (define (deep-member? X ls) (let ((maybe-x (an-atom-of ls))) (require (equal? x maybe-x)) #t)) 4. Fill in the blanks: > (define (choose-member L R) (cond ((null? R) (amb)) ((= (car L) (car R)) (car L)) (else (amb (choose-member L (cdr R)) (choose-member (cdr L) R))))) > (choose-member (1 2 3) (4 2 3)) 3 > try-again 2 > try-again 2 Chung Wu; CS61A, Spring 2004 2...
View Full Document
This note was uploaded on 08/07/2010 for the course COMPUTER S 61A taught by Professor Harvey during the Spring '06 term at University of California, Berkeley.
- Spring '06