| |
|
Chris Sauls 
| .remove for non associative arrays wrote:
> I think it would make sense if D had buit in way to remove alements from arrays.
> Something like array.remove(2..6); or array.remove(2,6); maybe?
# // remove elements from an [dynamic] array
# public template remove (T:T[]) {
# T[] remove (
# in T[] arr , // source array
# in int idx1, // first item to be removed
# in int idx2 // bounds
# )
# out {
# assert (result.length == (arr.length - (idx2 - idx1)));
# }
# body {
# T[] result = arr[0 .. idx1] ~ arr[idx2 .. arr.length];
# return result;
# }
# }
Although I agree it would be nice to have, as its a fairly common operation. And would be "consistant" in at least one sense with the new .remove() function for associative arrays.
-- Chris Sauls
|