Re: Passing functions to functionals

2010-12-01 Thread Lars T. Kyllingstad
On Tue, 30 Nov 2010 18:49:56 +0300, Dmitry Olshansky wrote: > On 30.11.2010 14:59, Lars T. Kyllingstad wrote: >> In my library I have a lot of functionals (functions that take other >> functions as parameters). Here is an example that shows the style I >> use to define them: >> >> // Example

Re: Passing functions to functionals

2010-11-30 Thread Jesse Phillips
Lars T. Kyllingstad Wrote: > // Same as above, using template alias parameter. > auto eval(alias f, X)(X x) { return f(x); } > > // Test > void main() > { > int add2(int i) { return i + 2; } > assert (eval!add2(1) == 3); > } > > I'd be grateful if people w

Re: Passing functions to functionals

2010-11-30 Thread Dmitry Olshansky
On 30.11.2010 14:59, Lars T. Kyllingstad wrote: In my library I have a lot of functionals (functions that take other functions as parameters). Here is an example that shows the style I use to define them: // Example: Evaluate the function/delegate/functor f at x. auto eval(F, X)(F f,

Passing functions to functionals

2010-11-30 Thread Lars T. Kyllingstad
In my library I have a lot of functionals (functions that take other functions as parameters). Here is an example that shows the style I use to define them: // Example: Evaluate the function/delegate/functor f at x. auto eval(F, X)(F f, X x) { return f(x); } // Test void main()