Chapter 2. Core concepts in functional programming

 

This chapter covers

  • Understanding concepts and foundations
  • Programming with immutable data
  • Reasoning about functional code
  • Working with functional data types and values

If you ask three functional programmers what they consider the most essential aspect of the functional paradigm, you are likely to get three different answers. The reason is that functional programming has existed for a long time and there’s a wide range of diverse programming languages. Every language emphasizes a different set of aspects while giving less importance to others. Most of the concepts are to some extent present in all functional languages.

The central part of this chapter focuses on these common ideas, exploring the basic features and techniques that functional programmers have in their toolset. We’ll investigate the concepts from a high-level perspective, and you’ll see how they fit together to form one coherent way of tackling problems.

2.1. The foundation of functional programming

2.2. Evaluation of functional programs

2.2.1. Working with immutable values

2.2.2. Using immutable data structures

2.2.3. Changing program state using recursion

2.2.4. Using expressions instead of statements

2.2.5. Computation by calculation

2.3. Writing declarative code

2.3.1. Functions as values

2.3.2. Higher-order functions

2.4. Functional types and values

2.4.1. Type inference in C# and F#

2.4.2. Introducing the discriminated union type

2.4.3. Pattern matching

2.4.4. Compile-time program checking

2.5. Summary

sitemap