I tried to make a template that receive lambda expression to apply it on a given range the user specifies, but I found non-understood problem:

'''D

module main;

import std.stdio;
import std.functional;


    template foo(alias predicate)
    if (is(typeof(unaryFun!predicate)))
    {
        alias notfunny=unaryFun!predicate;

auto foo(Range)(Range range) if (isInputRange!(Unqual!Range)){

        foreach(x; range)
            notfunny(x);

        return range;}


}


int main()
{

        int[] lolo = [12, 66, 654, -98, 54];

        lolo.foo(a=>a+2);

        lolo.writeln;

        return 0;
    }
    '''

Reply via email to