;;; hw6.ss YOUR NAME 4/29/16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; PART 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define ACIDS '( ((U U U) F) ((U U C) F) ((U U A) L) ((U U G) L) ((U C U) S) ((U C C) S) ((U C A) S) ((U C G) S) ((U A U) Y) ((U A C) Y) ((U A A) *) ((U A G) *) ((U G U) C) ((U G C) C) ((U G A) *) ((U G G) W) ((C U U) L) ((C U C) L) ((C U A) L) ((C U G) L) ((C C U) P) ((C C C) P) ((C C A) P) ((C C G) P) ((C A U) H) ((C A C) H) ((C A A) Q) ((C A G) Q) ((C G U) R) ((C G C) R) ((C G A) R) ((C G G) R) ((A U U) I) ((A U C) I) ((A U A) I) ((A U G) M) ((A C U) T) ((A C C) T) ((A C A) T) ((A C G) T) ((A A U) N) ((A A C) N) ((A A A) K) ((A A G) K) ((A G U) S) ((A G C) S) ((A G A) R) ((A G G) R) ((G U U) V) ((G U C) V) ((G U A) V) ((G U G) V) ((G C U) A) ((G C C) A) ((G C A) A) ((G C G) A) ((G A U) N) ((G A C) N) ((G A A) E) ((G A G) E) ((G G U) G) ((G G C) G) ((G G A) G) ((G G G) G) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; PART 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define ANIMALS '(dog (bird (horse () ()) (cat () ())) (possum (dog () ()) ()))) ;;; returns #t if tree is an empty tree (i.e., null), else false (define (empty-tree? tree) (null? tree)) ;;; returns the root of a binary tree structure (define (root tree) (if (empty-tree? tree) 'ERROR (car tree))) ;;; returns the left subtree of a binary tree structure (define (left-subtree tree) (if (empty-tree? tree) 'ERROR (cadr tree))) ;;; returns the right subtree of a binary tree structure (define (right-subtree tree) (if (empty-tree? tree) 'ERROR (caddr tree))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; PART 3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; generates a stream defined by the arithmetic sequence (start start+step start+2*step ...) (define (arithSequence start step) (cons start (delay (arithSequence (+ start step) step)))) ;;; returns a list containing the first len elements of the stream (define (lazyHead stream len) (if (or (null? stream) (zero? len)) '() (cons (car stream) (lazyHead (force (cdr stream)) (sub1 len)))))