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?


Reply via email to