On Monday, 18 March 2013 at 09:15:50 UTC, Knud Soerensen wrote:

First writeln() actually edit the original array, so when you filter it for the second array, fneg gives true for all clist[][][] elements.

How would you get around this ?

You should work on a whole copy of clist array.
Or return copy of elements from map function instead of the element itself (<-- faster and lazy solution, i guess)

To get a whole copy you can try to do something like this:

T recursiveDup(T)(ref T array) if (isArray!T)
{
        T retVal = array.dup;
        foreach(ref e; retVal)
                static if (isArray!(typeof(e)))
                        e = recursiveDup(e);

        return retVal;
}

gives you a copy of your array. It's a simple code, that works just for your specific case - not so efficient :)

Reply via email to