Chapter 8. Functional Data Structures
We are familiar with imperative data structures. In fact, there are lots of references to imperative data structures in different programming languages. In contrast, there aren't many references to declarative data structures or functional data structures. This is because FP languages are not as mainstream as imperative programming languages. Additionally, designing and implementing functional data structures is more difficult in comparison to imperative counterparts because of the following reasons:
- Mutability is not recommended in FP
- Functional data structures are expected to be more flexible than their imperative counterparts
Imperative data structures rely heavily on mutability and assignments and making them immutable needs extra development effort. Whenever we change an imperative data structure, we basically override the previous version; however, this is not the case with declarative programming as we expect that both the previous and new versions...