Inbuilt STL Algorithms & Lambda Function
(all_of, any_of, none_of, lamda function.) this are the functions .
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<[](int x){return x+2;}(2)<<endl;
// cout<<[](int x,int y){return x+y;}(2)<<endl;
vector<int>v={2,4,-6};
cout<<all_of(v.begin(),v.end(),[](int x){return x>0;})<<endl;
cout<<any_of(v.begin(),v.end(),[](int x){return x>0;})<<endl;
cout<<none_of(v.begin(),v.end(),[](int x){return x==3;})<<endl;
}
Comments
Post a Comment