How to Design Programs phần 2 pps
... following expressions: 1. (distance -to- 0 (make-posn 3 4)) 2. (distance -to- 0 (make-posn (* 2 3) (* 2 4))) 3. (distance -to- 0 (make-posn 12 (- 6 1))) by hand. Show all steps. Assume that sqr ... Hints: (1) Remember to develop auxiliary functions when a definition becomes too large or too complex to manage. (2) The function reveal consumes two structures and one ato...
Ngày tải lên: 12/08/2014, 19:20
... exercises 2. 2.1, 2. 2 .2, 2. 2.3, and 2. 2.4 as claims. Testing: Writing tests as claims is good practice, though we need to know more about equality to develop good automatic tests. To do so, ... equations into Scheme functions: 1. 4 · n + 2 = 62 2. 2 · n 2 = 1 02 3. 4 · n 2 + 6 · n + 2 = 4 62 Determine whether 10 , 12 , or 14 are solutions of these equati...
Ngày tải lên: 12/08/2014, 19:20
... (define (product-from -20 n-above -20 ) (cond [(= n-above -20 20 ) ] [else (product-from -20 (sub1 n-above -20 )) ])) The input n-above -20 is either 20 or larger. If it is 20 , it does not have ... product-from -20 : ;; product-from -20 : N [>= 20 ] -> N ;; to compute n · (n - 1) · · 21 · 1 (define (product-from -20 n-above -20 ) ) Here is a first example for...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 4 ppt
... 16 .2. 3. Show how to model a directory with two more attributes: a size and a systems attribute. The former measures how much space the directory itself (as opposed to its files and subdirectories) ... TEAM FLY PRESENTS -20 2- 1. (first alon1) evaluates to the first item on the list of pay-rates; 2. (first alon2) evaluates to the first item on the li...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 5 docx
... ((define x2 (* x x)) (define y2 (* y y))) (sqrt (+ x2 y2)))) (define x21 0) (define y21 1) (define x 22 9) (define y 22 16) (+ 1 (sqrt (+ x 22 y 22) )) By renaming x2 and y2 again, ... (local ((define x2 (* x x)) (define y2 (* y y))) (sqrt (+ x2 y2)))) (define x21 0) (define y21 1) (+ 1 (local ((define x2 (* 3 3)) (define y2 (* 4 4))) (sqrt (+ x2 y2)))) =...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 6 doc
... circle that are 120 degrees apart. For example, they could be at 0, 120 , 24 0: (define CENTER (make-posn 20 0 20 0)) (define RADIUS 20 0) ;; cicrcl-pt : number -> posn ;; to compute a position ... -28 3- Exercise 23 .1.1. Use local to create series-local from series-even and series-odd. Show with a hand-evaluation that (series-local make-even) is equivalent to...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 7 ppt
... with rel -2- abs shows how much the use of an accumulator simplifies the conversion process: = (rel -2- abs (list 3 2 7) 0) = (cons 3 (rel -2- abs (list 2 7) 3)) = (cons 3 (cons 5 (rel -2- abs (list ... vectors. A vector is a well-defined mathematical class of data with specific basic operations. For our purposes, it suffices to know how to construct them, how to extra...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 8 doc
... following list of inexact numbers: (define JANUS (list #i31 #i2e+34 #i-1 .23 4567890 123 5e+80 #i2749 #i -29 3 923 4 #i-2e+33 #i3.2e +27 0 TEAMFLY ... effects: (1) to initialize current-color; (2) to draw traffic light and ;; next : -> void ;; effects: (1) to change current-color from 'green to 'yellow, ;;...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 9 doc
... (lambda (x) 22 )) (define g f) (+ (begin (void) 5) (g 1)) = (define f (lambda (x) 22 )) (define g f) (+ 5 (g 1) ) = (define f (lambda (x) 22 )) (define g f) (+ 5 22 ) Scheme, however, ... (= (flip2) 0)) = (define state1 0) (define state2 1) (and true (= (begin (set! state2 (- 1 state2)) state2) 1) (= (flip2) 0)) = (define state1 0) (define state...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 10 potx
... [11], [ 12] , [13], [14], [15], [16], [17], [18], [19], [20 ], [21 ], [22 ], [23 ], [24 ], [25 ], [26 ], [27 ] design recipe, [2] , [3], [4], [5], [6], [7], [8], [9], [10], [11], [ 12] abstraction, [2] ... list-of-directories dir, [2] dir, [2] direction directory list-of-files list-of-files-and-directories root directory, [2] directory tree displacement displacement, [2]...
Ngày tải lên: 12/08/2014, 19:20