Can I pass a function by parameter?

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 7 14:02:15 PDT 2014


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


More information about the Digitalmars-d mailing list