On 14.12.2010 19:49, Simen kjaeraas wrote:
Stephan Soller <[email protected]> wrote:[1, 2, 3, 4, 5].select((int e){ return e > 3; }) .collect((int e){ return e*e; }); It's already fairly compact. The main overhead is the parameter type and the return statement. I don't believe this can be reduced any more without breaking consistency of the language.The delegates can be passed by alias parameter, and then be written without the parameter type: @property void bar(alias t)() { t(3); } void main() { bar!((e){writeln(e);}); }
Hm, nice trick, thanks Simen. Looks interesting and more general to use. Will try that for my next D project.
Happy programming Stephan Soller
