Re: delegate from lambda expression

2012-09-10 Thread Jacob Carlborg
On 2012-09-10 01:20, timotheecour wrote: I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=>a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is inferred

Re: delegate from lambda expression

2012-09-09 Thread Timon Gehr
On 09/10/2012 02:56 AM, bearophile wrote: timotheecour: What was wrong with it and what would you suggest to improve it? Nothing serious, I just suggest to give a bit more air to your code, adding a space around operators, after commas, etc. Otherwise your code risk looking like Timon's code

Re: delegate from lambda expression

2012-09-09 Thread bearophile
timotheecour: What was wrong with it and what would you suggest to improve it? Nothing serious, I just suggest to give a bit more air to your code, adding a space around operators, after commas, etc. Otherwise your code risk looking like Timon's code ;-) I have also compiled the code with

Re: delegate from lambda expression

2012-09-09 Thread timotheecour
Thanks! the template alias ID solves my problem. Your code doesn't look good, What was wrong with it and what would you suggest to improve it? Also, I noticed you replaced (among other things): a.map!dg.array by a.map!dg().array() Will the way I'm skipping "()" ever be deprecated? One of th

Re: delegate from lambda expression

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:20 AM, timotheecour wrote: I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=>a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is inferr

Re: delegate from lambda expression

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:55 AM, bearophile wrote: Your code doesn't look good, Yes it does.

Re: delegate from lambda expression

2012-09-09 Thread bearophile
timotheecour: I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=>a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is inferred from initializer delegate (_

Re: delegate from lambda expression

2012-09-09 Thread bearophile
Because in D there is no global inferencer, On the other hand it's not impossible to invent a syntax for templated lambdas, etc :-) Bye, bearophile

delegate from lambda expression

2012-09-09 Thread timotheecour
I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=>a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is inferred from initializer delegate (__T26 a) { retur