- Good website to learn lambda in c++:
https://docs.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp
https://en.cppreference.com/w/cpp/language/lambda
https://www.geeksforgeeks.org/lambda-expression-in-c/
https://stackoverflow.com/questions/7627098/what-is-a-lambda-expression-in-c11
https://linuxhint.com/lambda-expressions-in-c/
[ captureClause ] ( parameters ) -> returnType
{
statements;
}
#include <iostream>
using namespace std;
bool isGreater = [](int a, int b){ return a > b; }
int main() {
cout << isGreater(5, 2) << endl; // Output: 1
return 0;
}
//lambda function for sorting vector ascending
sort(vec.begin(),vec.end(),[](int &a, int &b){
return a<b;
});
//lambda function for sorting vector of vector ascending based on first value
sort(vec.begin(),vec.end(),[](vector<int> &a, vector<int> &b){
return a[0]<b[0];
});
Code Example |
---|
Cpp :: after login redirect to dashboard in nuxt |
Cpp :: getline |
Cpp :: set to vector |
Cpp :: c++ doubly linked list |
Cpp :: inserting element in vector in C++ |
Cpp :: c++ Least prime factor of numbers till n |
Cpp :: c++ convert const char* to int |
Cpp :: how to generate number in c++ |
Cpp :: transformer in nlp |
Cpp :: how to create 2d array using vector in c++ |
Cpp :: c++ get last element in vector |
Cpp :: C++ String Compare Example |
Cpp :: inheritance in c++ |
Cpp :: accumulate vector c++ |
Cpp :: calculator in cpp |
Cpp :: double array c++ |
Cpp :: changing values of mat in opencv c++ |
Cpp :: uparam(ref) |
Cpp :: create new node in tree |
Cpp :: print fps sfml |
Cpp :: c++ regex count number of matches |
Cpp :: ue4 int to enum c++ |
Cpp :: recursive factorial of a number |
Cpp :: c++ linked list delete node |
Cpp :: c++ swap function |
Cpp :: c++ sorting and keeping track of indexes |
Cpp :: c++ linked list |
Cpp :: how to create a struct in c++ |
Cpp :: find second largest number in array c++ |
Cpp :: ? c++ |