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