mercredi 2 novembre 2016

How to make a C++ intention list

I would like to make an intention list like python does.

list = [1,2,3,4]
newList = [ i * 2 for i in list ] 

Using std,iterator and lambda function, it should be possible to do the same things in one line.

std::vector<int> list = {1,2,3,4} ; 
std::vector<int> newList = 

Could you complete it ?

Aucun commentaire:

Enregistrer un commentaire