Miranda
The Craft of Functional Programming

Errata


p 9 The comment before the square function should read `To square a number'.

p 78 In the equation on line -9, the comment should read `by (1),(2)'.

p 79 The equation in the middle of the page should be

sumPowers n = power2 (n+1) - 1

p 144 Line -5, replace double by times2.

p 173 Replace double by times2, twice.

p 175 Replace doubleList by double, four times.

p 190 Add to the principle of extensionality `of the appropriate type'.

p 190 Exercise 7.21, replace all occurrences of swap by converse.

p 195 Exercise 7.29, in the equation replace the `&' by `$both' and add the words

where both p q x = p x & q x.

p 205 At the foot of the page in the comment on (1), the roles of [num] and [bool] should be reversed.

p 208 The first paragraph should read: `The expression in each clause on the right-hand side of an equation must unify to some type at least as general as the type declared for the result of the function.'

p 218 The type of showPerson should be people -> string.

p 224 The type of showExpr should be expr -> string.

p 230 The type of bEval should be bExp -> bool.

p 240 There should not be a space between :: and = in definitions of edit.

p 275 The definition of the queue implementation should read

queue * == ([*],[*])

Section 11.7 Note that the join function is implemented in such a way that it only guarantees that its result is a search tree if all elements of the first argument are smaller than all elements of the second.

p 289 The implementation of insert given in the book is incorrect. It should take account of whether the value val is a member of the tree (Node v n t1 t2) when calculating the size of the resulting tree. We therefore need to write

insert val (Node v n t1 t2) = Node v n t1 t2 , if v=val = Node v (1 + size t1 + size nt2) t1 nt2 , if val > v = Node v (1 + size nt1 + size t2) nt1 t2 , if val < v where nt1 = insert val t1 nt2 = insert val t2

p 321 The type of routes should be

relation * -> * -> * -> [[*]]

p 323 The type of routesC should be

relation * -> * -> * -> [*] -> [[*]]

p 328 The displayed block in the middle of the page should begin with the line

(digList $do digsToNum) "21a3"

p 331 Exercise 12.12. The type of the function charlistToExpr should be

charlistToExpr :: [char] -> expr
with the examples being
charlistToExpr "234" = Lit 234
and so on.

p 347 The local definition should read

waitTime (Discharge t w s) = w

p 371 Exercise 13.28, In the second equation replace & by $both. Add after the equations the line `where both is defined in Exercise 7.29.'.

p 382 The second clause on the right hand side of the definition of mSort1 in exercise 14.14 should be followed by , otherwise.

p 397 Exercise 14.24, the first word should be `Give'.

p 418 The three equations at the foot of the page should be labelled (4), (5), (6).

p 425 On the first line, `being' should be `begin'.


Written 26 April 1995.
Last modified 12 August 1997.