Purely Functional Data StructuresMost books on data structures assume an imperative language such as C or C++. However, data structures for these languages do not always translate well to functional languages such as Standard ML, Haskell, or Scheme. This book describes data structures from the point of view of functional languages, with examples, and presents design techniques that allow programmers to develop their own functional data structures. The author includes both classical data structures, such as red-black trees and binomial queues, and a host of new data structures developed exclusively for functional languages. All source code is given in Standard ML and Haskell, and most of the programs are easily adaptable to other functional languages. This handy reference for professional programmers working with functional languages can also be used as a tutorial or for self-study. |
What people are saying - Write a review
User ratings
5 stars |
| ||
4 stars |
| ||
3 stars |
| ||
2 stars |
| ||
1 star |
|
This is a great book. An improved version of Okasaki's PhD thesis, the book introduces the reader to the notion of efficient data structures which still get to be purely functional (i.e. not imperative, no side-effects).
A common problem with purely functional data structures is that, since there is no state, we can't change the value of a variable once it has been assigned. We can always create a new variable with the same exact name, but it will be a completely new variable and any pointer to the previous variable would be lost. This is called Persistency. Persistency makes building efficient purely functional data structures and algorithms, even for basic tree searching and sorting, an intricate craft.
In this book, we are presented with an arsenal of techniques to build purely functional data structures which are efficient in the sense that they compete well with imperative counterparts. The book uses lazy evaluation and memoization as the keys to unlock efficiency. The algorithms are presented as working code in Standard ML (and in Haskell in the appendix) which is great. Everything is very well explained and rigorous. Techniques for computing the complexity of algorithms are already presented (banker's method and physicist method).
Make no mistake. This is not an introduction to functional languages. Knowledge of those languages is assumed and, although an experienced programmer in other kind of languages may profit from it without knowing any functional languages, if you are looking for an introduction, buy something else.
Having said that, if you are familiar with Haskell or ML (any dialect), this is book is a great way to both (1) learn important techniques that you can apply when building your own data structures and algorithms and (2) as a reference for basic functional data structures and algorithms (ordered sets, red-black trees, etc).
I did buy this book and I am very pleased with it.
Contents
Introduction | 1 |
12 Strict vs Lazy Evaluation | 2 |
13 Terminology | 3 |
14 Approach | 4 |
Persistence | 7 |
22 Binary Search Trees | 11 |
23 Chapter Notes | 15 |
Some Familiar Data Structures in a Functional Setting | 17 |
71 Scheduling | 84 |
72 RealTime Queues | 86 |
73 Binomial Heaps | 89 |
74 BottomUp Mergesort with Sharing | 94 |
75 Chapter Notes | 97 |
Lazy Rebuilding | 99 |
82 Global Rebuilding | 101 |
83 Lazy Rebuilding | 104 |
32 Binomial Heaps | 20 |
33 RedBlack Trees | 24 |
34 Chapter Notes | 29 |
Lazy Evaluation | 31 |
42 Streams | 34 |
43 Chapter Notes | 37 |
Fundamentals of Amortization | 39 |
52 Queues | 42 |
53 Binomial Heaps | 45 |
54 Splay Heaps | 46 |
55 Pairing Heaps | 52 |
56 The Bad News | 54 |
57 Chapter Notes | 55 |
Amortization and Persistence via Lazy Evaluation | 57 |
62 Reconciling Amortization and Persistence | 58 |
63 The Bankers Method | 61 |
64 The Physicists Method | 68 |
65 Lazy Pairing Heaps | 79 |
66 Chapter Notes | 81 |
Eliminating Amortization | 83 |
84 DoubleEnded Queues | 106 |
85 Chapter Notes | 113 |
Numerical Representations | 115 |
91 Positional Number Systems | 116 |
93 Skew Binary Numbers | 130 |
94 Trinary and Quaternary Numbers | 138 |
95 Chapter Notes | 140 |
DataStructural Bootstrapping | 141 |
101 Structural Decomposition | 142 |
102 Structural Abstraction | 151 |
103 Bootstrapping To Aggregate Types | 163 |
104 Chapter Notes | 169 |
Implicit Recursive Slowdown | 171 |
112 Catenable DoubleEnded Queues | 175 |
113 Chapter Notes | 184 |
Haskell Source Code | 185 |
207 | |
217 | |