Chapter 3. Meet tuples, lists, and functions in F# and C#

 

This chapter covers

  • Declaring functions and values
  • Working with immutable tuples and lists
  • Processing lists using recursion
  • Parameterizing processing functions

In chapter 2, we explored the most important concepts of functional programming, but we did this from a high-level perspective. We haven’t shown you any real functional code, aside from quick examples to demonstrate our ideas. Our goal so far has been to illustrate how concepts relate to one another and how the result is a very different approach to programming.

In this chapter you’ll finally get to write functional F# code, but we’ll focus on examples that can be nicely explained and demonstrated using C#. We won’t yet delve into the details; you’ll learn more about those in part 2.

Here’s a brief look at this chapter’s topics:

3.1. Value and function declarations

3.1.1. Value declarations and scope

3.1.2. Function declarations

3.1.3. Declaring mutable values

3.2. Using immutable data structures

3.2.1. Introducing tuple type

3.2.2. Implementing a tuple type in C#

3.2.3. Calculating with tuples

3.2.4. Pattern matching with tuples

3.3. Lists and recursion

3.3.1. Recursive computations

3.3.2. Introducing functional lists

3.3.3. Functional lists in C#

3.3.4. Functional list processing

3.4. Using functions as values

3.4.1. Processing lists of numbers

3.4.2. Benefits of parameterized functions

3.5. Summary

sitemap