Da_Gamer icon

C# to C++ lambda

Da_Gamer | PRO | 02/29/16 08:58:28 PM UTC | 0 ⭐ | 275 πŸ‘οΈ | Never ⏰ | []
C# |

340 B

|

None

|

0 πŸ‘

/

0 πŸ‘Ž

//C#
List<int> elements = new List<int>() { 10, 20, 31, 40 };
// ... Find index of first odd element.
int oddIndex = elements.FindIndex(x => x % 2 != 0);
Console.WriteLine(oddIndex);
Β 
//C++
Vector<int> elements = { 10, 20, 31, 40 };
int oddIndex = elements.findIndex(begin, end, [](int x) {return x % 2 != 0});
cout << oddIndex << endl;

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    πŸ‘

    /

    πŸ‘Ž