Chapter 5. Data handling with lists

 

This chapter covers

  • Classifying data structures in functional programming
  • Using the ubiquitous singly linked list
  • Understanding the importance of immutability
  • Handling lists with recursion and functions

Data structures are among the most important concepts in programming, as well as in everyday life. The world as we see it is itself a huge data structure composed of simpler data structures, which are in turn composed of simpler structures. Each time we try to model something, be it objects or facts, we end up with data structures.

There are many types of data structures. In computing, data structures are generally represented as a whole by the term collections. A collection is a group of data items that have some relation to each other. In the simplest form, this relation is the fact that they belong to the same group.

5.1. How to classify data collections

Data collections can be classified from many different points of view. You can classify data collections as linear, associative, and graph:

5.2. An immutable, persistent, singly linked list implementation

5.3. Data sharing in list operations

5.4. Using recursion to fold lists with higher-order functions

5.5. Summary