On 02/14/2012 12:59 PM, RenatoL wrote:
mmmhhh.... this is interesting nevertheless i don't understand the
solution of my problem, and i cannot even understand it's origin:

void main()
{
     string s1 = "abcd";
     s1 = s1[stride(s1,0)..1] ~ 'r' ~ s1[2..$];
     writeln(s1);
}

why there is not way i cannot achive "arcd"?

import std.stdio;
import std.utf;

void main()
{
    string s1 = "abcd";

    immutable firstCharStride = stride(s1, 0);
    immutable secondCharStride = stride(s1, firstCharStride);

    auto firstPart = s1[0..firstCharStride];
    auto lastPart = s1[firstCharStride + secondCharStride..$];

    s1 = firstPart ~ 'r' ~ lastPart;
    writeln(s1);
}

Ali

Reply via email to