List of Listings

 

Chapter 1. Introducing functional programming

Listing 1.1. Functional approach: Where and OrderBy don’t affect the original list

Listing 1.2. Nonfunctional approach: List<T>.Sort sorts the list in place

Listing 1.3. Mutating state from concurrent processes yields unpredictable results

Listing 1.4. C# 6 and C# 7 features relevant for FP

Listing 1.5. Declaring a delegate

Listing 1.6. Instantiating and using a delegate

Listing 1.7. Declaring a function inline with a lambda

Listing 1.8. Lambdas have access to variables in the enclosing scope

Listing 1.9. A function can be exhaustively represented with a dictionary

Listing 1.10. Where: a typical HOF that iteratively applies the given predicate

Listing 1.11. A HOF that optionally invokes the given function

Listing 1.12. Connecting to a DB requires some setup and teardown

Listing 1.13. Duplication of setup/teardown logic

Listing 1.14. Encapsulating setup and teardown of the database connection into a HOF

Listing 1.15. A HOF that can be used instead of the using statement

Chapter 2. Why function purity matters

Listing 2.1. A list formatter combining pure and impure functions

Listing 2.2. Generating a range of integers

Listing 2.3. Combining elements from parallel lists with Zip

Listing 2.4. List formatter refactored to use pure functions only

Listing 2.5. A pure implementation that executes in parallel

Listing 2.6. Parameterized tests allow you to check your code in a variety of situations