How to Design Programs phần 1 pot
... that show the reader how to analyze a problem statement; how to formulate concise goals; how to make up examples; how to develop an outline of the solution, based on the analysis; how to finish ... Simple Lists 10 More on Processing Lists 10 .1 Functions that Produce Lists 10 .2 Lists that Contain Structures 10 .3 Extended Exercise: Moving Pictures 11 Natu...
Ngày tải lên: 12/08/2014, 19:20
... requires 11 uses of list in contrast to 40 of cons and 11 of empty . Exercise 13 .1. 1. Use cons and empty to construct the equivalent of the following lists: 1. (list 0 1 2 3 4 5) ... add -to- pi : N -> number ;; to compute n + 3 .14 without using + (define (add -to- pi n) (cond [(zero? n) 3 .14 ] [else (add1 (add -to- pi (sub1 n)))])) Figure 32: Adding a...
Ngày tải lên: 12/08/2014, 19:20
... [5], [6] top-level variable, [2], [3], [4], [5] definition window, [2], [3], [4], [5], [6], [7], [8], [9], [10 ], [11 ], [12 ], [13 ], [14 ], [15 ], [16 ], [17 ], [18 ], [19 ], [20], [ 21] , [22], [23], ... as (list 1. 10 1. 12 1. 08 1. 09 1. 11) and produces (list 1. 10 329/300 82/75) in return. Develop the function vector-3-averages , which computes the 3-item sliding ave...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 2 pps
... Exercise 6 .1. 1. Evaluate the 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 ... Thus, (distance -to- 0 (make-posn 3 4)) = 5 (distance -to- 0 (make-posn 8 6)) = 10 (distance -to- 0 (make-posn 5 12 )) = 13 Once we have examples, we can turn ou...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 4 ppt
... lists together. Examples: (merge (list 1 3 5 7 9) (list 0 2 4 6 8)) ;; expected value: (list 0 1 2 3 4 5 6 7 8 9) (merge (list 1 8 8 11 12 ) (list 2 3 4 8 13 14 )) ;; expected value: (list 1 ... parallel. Exercise 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...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 5 docx
... versions of max with (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) Explain the effect. Exercise 18 .2 .13 . Develop the function to- blue-eyed-ancestor. The function consumes a family ... list-processing Exercise 21. 2 .1. Use build-list 1. to create the lists (list 0 3) and (list 1 4) ; 2. to create the list (list .1 . 01 .0 01 .00 01) ;...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 6 doc
... the following example, however: (gcd-structural 10 113 5853 45 014 640) The result is 17 7 and to get there gcd-structural had to compare 10 113 5676, that is, 10 113 5853 - 17 7, numbers. This is ... important to document the problem generation with good examples and to give a good termination argument. Exercise 26.3.5. Evaluate (quick-sort (list 10 6 8 9 14 12 3 1...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 7 ppt
... vector-sum-aux : (= (vector-sum-aux (vector -1 3/4 1/ 4) 3) 0) (= (vector-sum-aux (vector .1 .1 .1 .1 .1 .1 .1 .1 .1 .1) 10 ) 1) (= (vector-sum-aux (vector) 0) 0) Unfortunately, this doesn't ... (= (vector-sum (vector .1 .1 .1 .1 .1 .1 .1 .1 .1 .1) ) 1) (= (vector-sum (vector)) 0) The last example suggests that we want a reasonable answer ev...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 8 doc
... numbers and the result is too small to fit into our class of inex structures: (inex* (create-inex 1 -1 10) (create-inex 1 -1 99)) = (create-inex 1 -1 109) which causes an error. When underflow ... which raises one number to the power of some integer. Using this function, conduct the following experiment. Add (define inex (+ 1 #i1e -12 )) (define exac (+ 1 1e -12...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 9 doc
... (define state1 1) (and (= (flip1) 0) (= (flip1) 1) (= (flip1) 0)) = (define state1 1) (and (= (begin (set! state1 (- 1 state1)) state1) 0) (= (flip1) 1) (= (flip1) 0)) = ... counter1 (+ 0 1) ) counter1) = (define counter1 0) (begin (set! counter1 1) counter1) = (define counter1 1) (begin (void) counter1 ) = (define counter1 1) 1...
Ngày tải lên: 12/08/2014, 19:20