Error: closures are not yet supported in CTFE
zeljkog via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 23 07:44:10 PST 2015
I tried:
--
import std.stdio, std.algorithm;
auto unique(){
bool[int] c;
return (int a){
if (a in c)
return false;
else{
c[a] = true;
return true;
}
};
}
void main()
{
[1, 5, 5, 2, 1, 5, 6, 6].filter!(unique()).writeln;
}
--
And got:
Error: closures are not yet supported in CTFE
This works:
void main()
{
auto x = unique();
[1, 5, 5, 2, 1, 5, 6, 6].filter!x.writeln;
}
Is first version near?
More information about the Digitalmars-d-learn
mailing list