Mistakes, Typos in "How to Design Programs"


The corrected version of this edition is available on-line. This contains several error fixes—please use that version rather than this one.


"How to Design Programs" contains the following mistakes:

  1. page 24 ( Composing Functions)

    The problem statement correctly specifies that "[d]ecreasing the price by a dime ($.10) increases attendance by 15." Later, the book includes the sentence "The base attendance at a price of five dollars is 120, and for each 15 cents less than five dollars, 10 more attendees show up." This second claim is incorrect.

    Thanks to Chuck Floyd, Kerrville, TX

  2. page 92 (figure 19) ( Composing Functions, Revisited)

    The book specifies that

      ;;A shape is either
      ;;1. a circle, or
      ;;2. a structure.
    
    This should be
      ;;A shape is either
      ;;1. a circle, or
      ;;2. a square.
    

    Thanks to Jamie Raymond, Houston, TX

  3. page 158 (exercise 11.3.1) ( Extended Exercise: Creating Lists, Testing Functions) page ???

    The book mistakenly specifies random as a function that consumes a natural number. Instead, random consumes an integer greater than or equal to 1 (and less than or equal to 2147483647.

    Thanks to Marvin D. Hernandez, Miami, FL

  4. page 172 ( Recursive Auxiliary Functions)

    The section switches from the development of a descending sort to that of an ascending sort during the transition from the development of sort to the development of insert.

    Figure 33 (page 175) should be as follows:

    ;; sort : list-of-numbers -> list-of-numbers
    ;; to create a list of numbers with the same numbers as
    ;; alon sorted in descending order
    (define (sort alon)
      (cond
        [(empty? alon) empty]
        [(cons? alon) (insert (first alon) (sort (rest alon)))]))
    
    ;; insert : number list-of-numbers (sorted) -> list-of-numbers
    ;; to create a list of numbers from n and the numbers on
    ;; alon that is sorted in descending order; alon is sorted
    (define (insert n alon)
      (cond
        [(empty? alon) (cons n empty)]
        [else (cond
    	    [(>= (first alon) n) (cons n alon)]
    	    [(<  (first alon) n) (cons (first alon) (insert n (rest alon)))])]))
    

    Thanks to Daniel P. Friedman, Bloomington, IN

  5. page 174 ( Recursive Auxiliary Functions)

    "make-structure" should be "make-mail".

  6. page 191, 192: ( Structures in Structures)

    (make-child empty empty 'Bettina 1950 'green)
    should be
    (make-child empty empty 'Bettina 1926 'green)
    (make-child (make-child empty empty 'Carl 1926 'green) 
                (make-child empty empty 'Bettina 1950 'green)
                'Adam 
    	    1950 
    	    'yellow)
    
    should be
    (make-child (make-child empty empty 'Carl 1926 'green) 
                (make-child empty empty 'Bettina 1926 'green)
                'Adam 
    	    1950 
    	    'yellow)
    
    (make-child (make-child empty empty 'Carl 1926 'green) 
                (make-child empty empty 'Bettina 1950 'green)
                'Dave
    	    1955
    	    'black)
    
    should be
    (make-child (make-child empty empty 'Carl 1926 'green) 
                (make-child empty empty 'Bettina 1926 'green)
                'Dave
    	    1955
    	    'black)
    

    Thanks to Marvin D. Hernandez, Miami, FL

  7. page 213, 216: ( Lists of Structures, Lists in Structures)

    ;; blue-eyed-descendant? : ftn -> boolean
    ;; to determine whether a-parent any of the descendants (children, 
    ;; grandchildren, and so on) have 'blue in the eyes field
    (define (blue-eyed-descendant? a-parent) ...)
    
    should be
    ;; blue-eyed-descendant? : parent -> boolean
    ;; to determine whether a-parent any of the descendants (children, 
    ;; grandchildren, and so on) have 'blue in the eyes field
    (define (blue-eyed-descendant? a-parent) ...)
    

    Thanks to Marvin D. Hernandez, Miami, FL

  8. page 376 ( Making Choices)

    The enumerations are missing a number each. Here are the correct versions:

      1.  18 is evenly divisible by 1, 2, 3, 6, 9, and 18; 
      2.  24 is evenly divisible by 1, 2, 3, 4, 6, 8, 12, and 24.
    

    Thanks to Daniel P. Friedman, Bloomington, IN

  9. page 451 ( Recognizing the Need for an Accumulator)

    The application of make-last-item in invert receives the arguments in the wrong order:
    (define (invert alox)
      (cond
        [(empty? alox) empty]
        [else (make-last-item (first alox) (invert (rest alox)))]))
    

    Thanks to Daniel P. Friedman, Bloomington, IN

  10. page 432 ( A First Look at Vectors)

    Figure 81 contains a mistake in the definition of vector-sum. Here is the correct version:

    ;; vector-sum : (vectorof number) -> number
    ;; to compute the sum of the numbers in v
    (define (vector-sum v) 
      (vector-sum-aux v (vector-length v)))
    

    Thanks to Nguyen Cong Vu, Open University, Ho Chi Minh City, Viet Nam

  11. page 558

    In exercise 38.4.3, part 3 the program is illegal in Advanced Scheme. Here is the corrected version:

    (define (make-box x)
           (local ((define contents x)
    	       (define (new y)
    		 (set! contents y))
    	       (define (peek)
    		 contents))
    	 (list new peek))
         newline
         (define B (make-box 55))
         (define C (make-box 'a))
         newline
         (begin
           ((first B) 33)
           ((second C)))
    

    Thanks to Dung X. Nguyen, Houston, TX.


The following problems occurred in the on-line version only:
  1. A Problem with Structural Processing

    The two pictures of dots on a line were unreadable due to the HTML converter.



They have been eliminated.

We have also found the following typos:

  1. page 7: "lanuages" should be "languages" (D.P. Friedman)
  2. page 16: "DrScheme's catches" should be "DrScheme catches" (D.P. Friedman)
  3. page 20: "for process" should be "for a process" (D.P. Friedman)
  4. page 27: "in the both columns column" should be "in both columns" (D.P. Friedman)
  5. page 81: wrong font for "first" in structure definition (D.P. Friedman)
  6. page 108: "must look the pragmatics" should be "must look at the pragmatics" (D.P. Friedman)
  7. page 134: "on on" should be "on" (D.P. Friedman)
  8. page 143: "a the" should be "the" (D.P. Friedman)
  9. page 172: "create a sorted list" should be "creates a sorted list" (D.P. Friedman)
  10. page 192: "conventions concerning on" should be "conventions concerning on" (D.P. Friedman)
  11. page 201: "tha is" should be "tha is" (D.P. Friedman)
  12. page 218: "fun-for-parent" should be "fun-parent", "for-for-loc" should be "fun-children" (D.P. Friedman)
  13. page 225: "directly apply to" should be "directly applies to" (D.P. Friedman)
  14. page 235: "that a natural" should be "that consumes a natural" (D.P. Friedman)
  15. page 239: "like list-pick0" should be "like list-pick" (D.P. Friedman)
  16. page 240: "consider the second part" should be "consider the first part" (D.P. Friedman)
  17. page 244: "data definition data definition" should be "data definition" (D.P. Friedman)
  18. page 244: "choses" should be "chooses"
  19. page 247: "if it the pattern" should be "if the pattern" (D.P. Friedman)
  20. page 253: "contain the numbers" should be "contain the same numbers" (D.P. Friedman)
  21. page 258: "test cases" should be "test" (D.P. Friedman)
  22. page 259: "a good \scheme{local} definitions" should be "a good understanding of \scheme{local} definitions" (D.P. Friedman)
  23. page 261: "Determine which of the following definitions or expressions is legal and which one is not:" should be "Determine which of the following definitions or expressions are legal and which ones are not:" (D.P. Friedman)
  24. page 263: "f-1' instead of f-11" should be "f-1' instead of f-1" (D.P. Friedman)
  25. page 264: "which of y's" should be "which of the y's" (D.P. Friedman)
  26. page 270: "For 'Sean," should be "For 'Wen," (D.P. Friedman)
  27. page 273: "in in" should be "in" (D.P. Friedman)
  28. page 274: "to write to" should be "to write two" (D.P. Friedman)
  29. page 295: the foonote was accidentally inlined (D.P. Friedman)
  30. page 316: "perparation" should be "preparation"
  31. page 327: "to obtain obtain" should be "to obtain" (D.P. Friedman)
  32. page 330: "functionq" should be "function" (D.P. Friedman)
  33. page 339: "to add just a few of the first few terms" should be "to add just the first few terms" (D.P. Friedman)
  34. page 358: "until drops" should be "until it drops off the table" (D.P. Friedman)
  35. page 369: "howthe it works" should be "how it works" (D.P. Friedman)
  36. page 373: "algorith" should be "algorithm"
  37. page 425: "a functions running time" should be "a function's running time" (D.P. Friedman)
  38. page 435: "veloicity" should "velocity" (Nguyen Cong Vu, Open University, Ho Chi Minh City, Viet Nam)
  39. page 437: "a vector of the same how-many as" should be "a vector of the same length as" (D.P. Friedman)
  40. page 441: "this loss make a" should be "this loss makes a" (D.P. Friedman)
  41. page 467: "this application \scheme{all-blue-eyed-ancestors} loses" should be "this application of \scheme{all-blue-eyed-ancestors} loses" (D.P. Friedman)
  42. page 474: "for the states we have reach so far" should be "for the states we have reached so far" (D.P. Friedman)
  43. page 477: "consume a the board" should be "consume a board" (D.P. Friedman)
  44. page 481: "choice is to round the number and to the closest representable equivalent" should be "choice is to round the number to the closest representable equivalent" (D.P. Friedman)
  45. page 504: "a variable \scheme{define}d at top-level variable" should be "a variable \scheme{define}d at top-level" (D.P. Friedman)
  46. page 504: "Supposed we evaluate" should be "Suppose we evaluate" (D.P. Friedman)
  47. page 517: "whether the functions has the desired result" should be "the function has the desired result and effect" (D.P. Friedman)
  48. page 518: "a particular good one" should be "a particularly good one" (D.P. Friedman)
  49. page 528: "Thus, the matching action is a build a word as long as chosen-word but to use '_ as the letters." should be "Thus, the matching action is to build a word as long as chosen-word from '_. (D.P. Friedman)
  50. pages 536/537: chosen-wor should be chosen-word (D.P. Friedman)
  51. page 566 "Alonzo Church in the last 1920s as follows:" should be "Alonzo Church in the late 1920s as follows:" (D.P. Friedman)
  52. page 595 "in the structure name p" should be "in the structure named p" (D.P. Friedman)
  53. page 616 "a self-referential descriptions" should be "a self-referential description" (D.P. Friedman)
  54. page 629 "preceeds" should be "precedes" (D.P. Friedman)
  55. page 631 (sorted-insert! 1 CLUBS hand0) should be (sorted-insert! 2 CLUBS hand0) (D.P. Friedman)
  56. page 635 "determing" should be "determining" (D.P. Friedman)
  57. page 636 "structure-mutating the functions" should be "structure-mutating functions" (D.P. Friedman)
  58. page 660 "related with each other" should be "related to each other" (D.P. Friedman)
  59. page 670 "cannot possible produce" should be "cannot possibly produce" (D.P. Friedman)
  60. page 678: "extrance" should be "entrance"

Matthias Felleisen