On Mon, 16 May 2011 15:53:38 -0400, Timon Gehr <timon.g...@gmx.ch> wrote:

In fact I even need to take that back. In order to work correctly, the
function would have to iterate downwards. It _is_ indeed buggy, and I
should stop emitting opinions when I'm short on time...

Andrei

Whoops, you are right:

void removeAt(T)(ref T[] arr, size_t index)
{
   foreach (i, ref item; retro(arr[1 .. index+1]))
        item = arr[i - 1];
    arr = arr[1 .. $];
}

Hehe, won't work.  Ranges can only support a single foreach parameter.

I think you may have to resort to for loops here (/me purposely ignores the hideous beast foreach_reverse). Be very careful with indexes on that one.

-Steve

Reply via email to