Can I pass a function by parameter?

AsmMan via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 7 14:32:25 PDT 2014


On Sunday, 7 September 2014 at 21:02:16 UTC, John Colvin wrote:
> On Sunday, 7 September 2014 at 20:47:47 UTC, AsmMan wrote:
>> I'm trying to use a bit of function programming.
>>
>> In a function like this:
>>
>> int f(in int[] arr, bool delegate(int) func);
>>
>> call using:
>>
>> bool g(int n) { ... }
>> f(arr, g);
>>
>> instead of:
>>
>> f(arr, x => x == 0);
>>
>> it is possible?
>
> bool g(int n) { ... }
> f(arr, &g);
>
> Also, these sort of questions are better in 
> http://forum.dlang.org/group/digitalmars.D.learn

Thanks.
And sorry for wrong area. I'll post there next time.

BTW, I'm answerning you after @Jakob Ovrum because I opened two 
new tabs and send @Jakob's one and had forget to send this...



More information about the Digitalmars-d mailing list