2 Getting started with functional programming

This chapter covers

  • Understanding higher-order functions
  • Using higher-order functions from the STL
  • Problems with composability of STL algorithms
  • Recursion and tail-call optimization
  • The power of the folding algorithm

The previous chapter showed a few neat examples of how to improve your code by using simpler functional programming techniques. We focused on benefits such as greater code conciseness, correctness, and efficiency, but we haven’t covered the special magic of functional programming languages that lets you write code in that manner.

The truth is, after you look behind the curtain, there’s no magic—just simple concepts with big consequences. The first simple yet far-reaching concept ...

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.