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) ... files and directories, they give us a good idea how such real-world programs work. Exercise 16.3.1. Translate the file system in figure 44 into a Scheme representation. Remember...
Ngày tải lên: 12/08/2014, 19:20
... vector-sum : (vectorof number) -> number ;; to sum up the numbers in v (define (vector-sum v) ) Here are some examples: (= (vector-sum (vector -1 3 /4 1 /4) ) 0) (= (vector-sum (vector ... 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,...
Ngày tải lên: 12/08/2014, 19:20
... 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 ... about how to organize programs. Adding pieces of functionality to a program demonstrates why programmers must follow a design discipline. Solving the problem again sh...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 2 pps
... for example, how to draw and erase a circle. Here we learn to translate a circle, that is, to move its representation along some line. In sections 7 .4, 10.3, and 21 .4 we learn to move entire ... 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...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 3 pot
... 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 natural number to ... ;; add -to- pi : N -> number ;; to compute n + 3. 14 without using + (define (add -to- pi n) ) Another easy step is to determine the output for a few sample inputs: (= (a...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 5 docx
... expected. 44 Exercise 18.2 .4. Since local definitions are added to the Definitions window during an evaluation, we might wish to try to see their values by just typing in the variables into the ... tree (ftn) (see section 14. 1) and produces a list that explains how to get to a blue-eyed ancestor. If there is no blue-eyed ancestor, the function produces false. TEAMFLY...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 6 doc
... smaller than or equal to TOLERANCE ? How does the answer to this question show that find-root produces an answer for all inputs that satisfy the assumption? Exercise 27.3 .4. For every midpoint ... 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 figu...
Ngày tải lên: 12/08/2014, 19:20
How to Design Programs phần 8 doc
... TEAM FLY PRESENTS -40 0- #i17 #i-2.4e+270 #i4.2 344 2 947 3 844 6e+170 #i1 #i-8e+269 #i0 #i99)) Determine the values (sum JANUS) ... draw-next-part to draw another part of the hangman figure. Of course, to accomplish this, hangman and check must have some memory about how often the ``Check'' button wa...
Ngày tải lên: 12/08/2014, 19:20
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
How to Design Programs phần 10 potx
... -5 14- 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 as ... [3], [4] , [5], [6], [7] data function, [2], [3], [4] , [5], [6], [7] local structure, [2], [3], [4] , [5], [6] top-level variable, [2], [3], [4] , [5] definition window, [2], [3], [4] , ... accumul...
Ngày tải lên: 12/08/2014, 19:20