hw1 - I(first x(sentence you(switch2(butfirst x(if(equal...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
;; 1.  ;; In this program, you input a number. It gets this number, produces random numbers,  and continues to   ;; produce random numbers until the random number is equal, or good-enough? , to the   square root of x.   ;; 2.  (define (squares x)   (if (equal? (length x) 0) ()   (sentence (* (first x) (first x)) (squares (butfirst x))))   ;; 3.  (define (switch x)  (if (equal?      you (first x)) (sentence      I (switch2 (butfirst x))) (switch2 x)))                                             (define (switch2 x)   (if (equal? (length x) 0) () (if (or (equal?      me (first x))       (equal?     
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: I (first x))) (sentence you (switch2 (butfirst x))) (if (equal? you (first x)) (sentence me (switch2 (butfirst x))) (sentence (first x) (switch2 (butfirst x))))))) ;; 4. (define (ordered? x) (if (equal? (length x) 1) (= 6 6) ((if (< (first x) (first (butfirst x))) (ordered? (butfirst x)) #f))) ;; 5. (define (ends-e x) (if (equal? (length x) 0) () ((if (equal? (last (first x)) e) (sentence (first x) (ends-e (butfirst x))) (ends-e (butfirst x)))))) ;; 6. (or (= 1 1) (/ 1 0)) (and (= 0 1) (/ 1 0))...
View Full Document

This note was uploaded on 11/30/2010 for the course EECS 21281 taught by Professor Harvey during the Spring '10 term at Berkeley.

Ask a homework question - tutors are online