Lambdas: The Functional Programming Companion of Modern C++

Daksh Gupta
6 min readFeb 16, 2018

Lambdas are one of the totally new addition to C++11 and has changed the way we write the code in C++. Any modern C++ code is incomplete without using lambdas which allow creation of in-place anonymous functions and transforms C++ into a full fledged Functional Programming Language.

Since the syntax as well as usage is relatively new, many C++ programmers still find it bit difficult to write and the usage scenarios.

This blog intends to describe the syntax, usage, and applicabilities of lambdas and how it helps in writing short, maintainable, functional and modern C++ code.

But before understanding what are lambdas and using the same, we need to understand a bit about Functional Programming

What is Functional Programming

In a nutshell, Functional Programming is all about writing the program functions similar to mathematical function. For example, consider the mathematical function

f(x)2 = x * x

This function returns the square of x and is an independent function which neither depends upon, nor impacts anything outside the function scope. Given an input x , the output will always be x

--

--

Daksh Gupta

🔹Software Product Development Consultant, Trainer, & Coach🔹 Tech Speaker & Content Creator 🔹 youtube.com/@Cognitive-Programmer 🔹 linkedin.com/in/iDaksh