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
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
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
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
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
On 09/10/2012 01:55 AM, bearophile wrote:
Your code doesn't look good,
Yes it does.
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 (_
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
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