How to Design Programs phần 5 docx

How to Design Programs phần 5 docx

How to Design Programs phần 5 docx

... look at how an application of add to some number evaluates: (define f (add 5) ) = (define f (local ((define (x-adder y) (+ 5 y))) x-adder)) = (define f (local ((define (x-adder5 y) (+ 5 y))) ... (local ((define (x-adder5 y) (+ 5 y))) x-adder5)) = (define (x-adder5 y) (+ 5 y)) (define f x-adder5) The last step adds the function x-adder5 to the collection of our d...

Ngày tải lên: 12/08/2014, 19:20

56 271 0
How to Design Programs phần 1 pot

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 ... marker refers to teacher hints, which suggest strategies on how to present a section, on how to approach an exercise, or on how to supplement some material. T...

Ngày tải lên: 12/08/2014, 19:20

57 290 0
How to Design Programs phần 2 pps

How to Design Programs phần 2 pps

... 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 our attention to the definition ... need the two coordinates to compute the distance. Put differently, we know how to combine two numbers into a posn structure using make-posn and we don't know how...

Ngày tải lên: 12/08/2014, 19:20

56 255 0
How to Design Programs phần 3 pot

How to Design Programs phần 3 pot

... expressions should evaluate to true : (dollar-store? empty) (not (dollar-store? (cons . 75 (cons 1. 95 (cons . 25 empty))))) (dollar-store? (cons . 75 (cons . 95 (cons . 25 empty)))) Generalize the ... shape position size(s) color circle (50 ,50 ) 40 red rectangle (30,20) 5 × 5 blue rectangle ( 65, 20) 5 × 5 blue rectangle (40, 75) 20 × 10 red rectangle ( 45, 35) 10...

Ngày tải lên: 12/08/2014, 19:20

56 267 0
How to Design Programs phần 4 ppt

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) ... binary search trees to store and to retrieve information. To be concrete, we discuss binary trees that manage information about people. In this context, a binary tree is similar...

Ngày tải lên: 12/08/2014, 19:20

56 317 0
How to Design Programs phần 6 doc

How to Design Programs phần 6 doc

... for (list 5) : (quick-sort (list 5) ) = (append (quick-sort (smaller-items 5 (list 5) )) (list 5) (quick-sort (larger-items 5 (list 5) ))) = (append (quick-sort (list 5) ) (list 5) (quick-sort ... the following example, however: (gcd-structural 1011 358 53 450 14640) The result is 177 and to get there gcd-structural had to compare 1011 356 76, that is, 101...

Ngày tải lên: 12/08/2014, 19:20

56 301 0
How to Design Programs phần 7 ppt

How to Design Programs phần 7 ppt

... counterexample. Consider the following table: plain factorial accumulator-style factorial 5. 760 5. 970 5. 780 5. 940 5. 800 5. 980 5. 820 5. 970 5. 870 6.690 5. 806 6.110 It represents the results for ... 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...

Ngày tải lên: 12/08/2014, 19:20

56 298 0
How to Design Programs phần 8 doc

How to Design Programs phần 8 doc

... master-check uses. Let us now study how the design recipe applies to the development of the program. The first step is to define the state variables and to specify the purpose of each variable. ... initialized; it is only used to compare to the two guesses of the player. The only other service we need is master-check . It uses check-color , the solution of exercise 5. 1...

Ngày tải lên: 12/08/2014, 19:20

56 257 0
How to Design Programs phần 9 doc

How to Design Programs phần 9 doc

... (listof traffic-light) ;; to manage the lights along Sunrise (define lights (list (make-traffic-light 'sunrise@rice 50 ) (make-traffic-light 'sunrise@cmu 150 ))) The result, however, ... individual traffic light. That is, in addition to switching from the current color to the next, an operator should be able to set a traffic light to red. The function for doing s...

Ngày tải lên: 12/08/2014, 19:20

56 227 0
How to Design Programs phần 10 potx

How to Design Programs phần 10 potx

... -51 4- 76 The notation (vectorof X) is analogous to (listof X) . 77 Scheme proper provides list mutators, and a Scheme programmer would use them to represent a hand ... TEAM FLY PRESENTS -52 6- index into the vector. Initially, the boundaries are 0 and (sub1 (vector-length V)) , which means that qsort-aux is to sort the entire vector. The definition ... [4], [5] , [6]...

Ngày tải lên: 12/08/2014, 19:20

60 240 0
w