How to Design Programs phần 9 doc
... 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 so already exists: ... effect: to change current-color from 'green to 'yellow, ;; 'yellow to 'red, and 'red to 'green (define (next) ) ;; next-color : TL-color -&...
Ngày tải lên: 12/08/2014, 19:20
... maintenance of software systems. To understand it better, we will next discuss a revision of Scheme's grammar and new ways to write contracts. Exercise 19. 2.2. Show how to use the abstracted version ... about Scheme can now use our function, too. To build a graphical user interface, we build structures 49 that correspond to the GUI items and hand them over to a GUI m...
Ngày tải lên: 12/08/2014, 19:20
... estimate is to the actual area. Let us agree that R stands for the number of rectangles that we wish to consider. To determine how large these rectangles are, we need to figure out how large ... 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 11 14 16 2...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 8 doc
... small 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 1 09) which causes an error. When ... 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 purpo...
Ngày tải lên: 12/08/2014, 19:20
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
How to Design Programs phần 2 pps
... 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 to extract these numbers ... letters, however, is not enough because the program also needs to maintain a word that records how much the second player has guessed. The solution is to add one extra ``lette...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 3 pot
... function how- many-numbers , which counts how many numbers are in a list of numbers. How do how- many-symbols and how- many-numbers differ? Exercise 9. 5.3. Develop the function dollar-store? , ... structure definition for an inventory that includes pictures with each object. Show how to represent the inventory listing in figure 29. 33 Develop the function show-picture ....
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) ... (define sample '( (99 o) (77 l) (24 i) (10 h) (95 g) (15 d) ( 89 c) ( 29 b) (63 a))) (define sample (list (list 99 'o)...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 7 ppt
... 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 extract values, and how to ... of vector-sum : (define (vector-sum v) (vector-sum-aux v (vector-length v))) Based on this definition, we can also adapt the examples for vector-sum to vector-sum-aux : (= (v...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 10 potx
... accumulator ) ]))) (rem! a-hand0 ) )) The questions to ask now are what the accumulator represents and what its first value is. The best way to understand the nature of accumulators is to study ... accumulator empty) Now the pieces of the design puzzle fall into place. The complete definition of the function is in figure 123. The accumulator parameter is renamed to predeces...
Ngày tải lên: 12/08/2014, 19:20