Hi, is there a way to remove a number of elements from an array by a range of indices in the standard library somewhere?

I wrote one (code below), but I'm wondering if there's a better way?

Also, can the below be made more efficient?

auto without(T, R)(T[] array, R indices) if (isForwardRange!R && isIntegral!(ElementType!R) && !isInfinite!R) {
    T[] newArray;
    ElementType!R start = 0;
    foreach (i; indices) {
        newArray ~= array[start .. i];
        start = i + 1;
    }
    newArray ~= array[start .. $];
    return newArray;
}

// Usage
long[] aa = [1, 2, 3, 4]
aa = aa.without([1, 3])

Thanks!

Reply via email to