"Timon Gehr" <timon.g...@gmx.ch> wrote in message 
news:jm2hnp$s0s$1...@digitalmars.com...
>
> (Well, the standard way to do what that python code does is using 
> templates.
>
> auto car_prices = map!(car => car.get_price)(list_of_cars);// lazy range
> auto car_prices = array(map!(car => car.get_price(list_of_cars)); // eager 
> array)
>

And keep in mind, too, even though those high-order functions take the 
delegate/closure as a template paramater, you CAN still rig it up for the 
delegate/closure to be changed at runtime (as long as the delegate's 
signature is the same):

auto myDelegate = (Car c) => c.getPrice;

// Change it at runtime:
if(foo)
    myDelegate = (Car c) => c.getPrice + 7;

auto carPrices = map!myDelegate(list_of_cars);


Reply via email to