Pearls of Functional Algorithm Design ハードカバー – 2010/9/16
Kindle 端末は必要ありません。無料 Kindle アプリのいずれかをダウンロードすると、スマートフォン、タブレットPCで Kindle 本をお読みいただけます。
Richard Bird takes a radical approach to algorithm design, namely, design by calculation. These 30 short chapters each deal with a particular programming problem drawn from sources as diverse as games and puzzles, intriguing combinatorial tasks, and more familiar areas such as data compression and string matching. Each pearl starts with the statement of the problem expressed using the functional programming language Haskell, a powerful yet succinct language for capturing algorithmic ideas clearly and simply. The novel aspect of the book is that each solution is calculated from an initial formulation of the problem in Haskell by appealing to the laws of functional programming. Pearls of Functional Algorithm Design will appeal to the aspiring functional programmer, students and teachers interested in the principles of algorithm design, and anyone seeking to master the techniques of reasoning about programs in an equational style.
'… well-presented and well-motivated material strives to become a stepping stone to further discovery. Any serious computer scientist would benefit from reading and properly understanding this book.' Computing Reviews
'… an excellent guide into this method of algorithm development.' Journal of Functional Programming
In this book, a "pearl" means starting with a brute force algorithm, then incrementally rewriting it into an efficient algorithm. Incrementally improving an algorithm sounds intriguing. In practice, the book just starts swapping out parts of the algorithm, accompanied by long descriptions of why it does not change the function's specification. Rarely does the book give reasoning about why the change is being made. After reading several of these pearls, my thought process does not jive with this style. I suspect the author actually wrote the final efficient algorithm first, then the brute force algorithm, and finally went back and crafted intermediate steps.
The book has many mistakes in it. Some are simply typos that most readers won't notice. Some mistakes invalidate multiple paragraphs in the proofs. Other times the book simply omits important details. For example, I spent an hour deciphering what the "building a tree with minimum height" algorithm did, but I was not convinced that the algorithm worked. I spent 2 days correcting a part of the proof that was wrong and filling in another important part that the book omitted, before I really believed that the algorithm worked.
A published errata could patch up those problems. However, there is no errata on the publisher's website. Nor can I find any way to contact Richard Bird and ask him to start one.
I've only read the first 8 pearls, but so far the problems those algorithms solve are definitely esoteric. Having worked 11 years as a professional developer, I have never come across any of those problems on the job or even as interview questions.
All that said, reading the book is still improving my functional programming.
Haskell is a perfect choice of language. However, I don't think this book is just for Haskell programmers. Some of most intriguing problems are covered in very good structure. My favorites are the coverage of saddleback search, last tail, raking suffixes and nexuses. All others topics are really well done, but these were the topics that I had hard time googling for a good explanation. Great work.
One quibble: the reader, to follow the arguments, will want to write the short code selections for himself, to check Bird's arguments; he'll find himself having to define a number of Unicode mathematical operators, like
U-2209, for example. But this isn't hard to do, in Haskell.
Each chapter is well-written, to the point, and closely argued. In showing the beauty of Haskell in a clear way, or showing the beauty of concrete maths in a clear way, Bird has done well.