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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.