On Sunday, 17 May 2015 at 09:57:05 UTC, Daniel Kozak wrote:

On Sun, 17 May 2015 09:39:21 +0000
Dennis Ritchie via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

I remembered code Ali Çereli. It really helped:
http://forum.dlang.org/thread/ulhtlyxxclihaseef...@forum.dlang.org#post-mihl6m:241che:241:40digitalmars.com

-----
import std.stdio, std.traits, std.range, std.algorithm;

auto deepDup(A)(A arr)
        if (isArray!A)
{
        static if (isArray!(ElementType!A)) {
                return arr.map!(a => a.deepDup).array;
                
        } else {
                return arr.dup;
        }
}


void main() {

        auto s = ["foo", "bar"].deepDup;

        s[1][1] = 't';

        writeln(s);
}
-----
http://rextester.com/QBFH12695

P.S. Need to enable deepDup in Phobos.

allready there:
auto s = ["foo", "bar"].map!"a.dup".array;

:)
Ouch ignore this one :D

Reply via email to