From the course: Introducing Functional Programming in C++

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

transform instead of map

transform instead of map - C++ Tutorial

From the course: Introducing Functional Programming in C++

Start my 1-month free trial

transform instead of map

- [Instructor] The first methods that newbie functional programmers learn are map, filter and reduce. A lot of languages, databases, and libraries have these methods, but unfortunately they don't exist in C++. But don't fret, we have substitutes available. Instead of map, filter and reduce, we have transform, copy if, and accumulate. These replacements aren't functional, nor are they pure, but they have been part of the C++ standard library since the 1990s. We could create implementations of them from scratch, but that usually isn't a good idea. The algorithms of the standard library have had over 20 years of optimizations and improvements. So let's go back to visual studio code. Let us go into file, new. And the first thing that we're going to do is we're going to add some include files. So we'll say include iostream, include algorithm, include vector, and finally, include numeric. Then we're going to save ourselves a little bit of typing by putting in using namespace std, and we'll…

Contents