Chapter 9. Thinking about data functionally

This chapter covers

  • The pitfalls of state mutation
  • Representing change without mutation
  • Enforcing immutability
  • Functional data structures

Greek philosopher Heraclitus said that we cannot step into the same river twice; the river constantly changes, so the river that was there a moment ago is no longer. Many programmers would disagree, objecting that it’s the same river but its state has now changed. Functional programmers try to stay true to Heraclitus’s thinking and would create a new river with every observation.

Most programs are built to represent things and processes in the real world, and because the world constantly changes, programs must somehow represent that change. The question is ...

Get Functional Programming in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.