2 Thinking in functions

This chapter covers

  • Functions in math and in programming
  • Representing functions in C#
  • Leveraging higher-order functions

In chapter 1, you saw how treating functions as first-class values is one of the tenets of FP. This allows the programmer to up the ante and write functions that are parameterized by or create other functions. These are called higher-order functions (HOFs); they really raise the level of abstraction in our programs, allowing us to do more with less code.

But before we delve into HOFs, let’s take a step back and see what we mean by functions: what they are both in the mathematical and programming jargon. We’ll then look at the various constructs that C# offers to represent functions.

2.1 What’s a function, ...

Get Functional Programming in C#, Second Edition 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.