#include <iostream>

int main()
{
    int counter = 0;
    
    //-----------------------------------------------
    //vvv Lambda vvv
    
    auto doSomething = [&counter](const std::string &str)
    {
    	++counter;
    	
        std::cout << "Called 'doSomething' " << counter << " times. "
                  << "Calling with with '" << str << "' as a parameter." << std::endl;
    };
    
    //'doSomething' is a variable that *holds* an instance of the lambda to call later, like a function pointer.

    //-----------------------------------------------
    
    doSomething("Penguin");
    doSomething("Aardvark");
    
    for(const std::string &element : {"fire", "water", "earth", "wind"})
    {
        doSomething(element);
    }
    
    return 0;
}