digitalmars.D - bobef
- .remove for non associative arrays <.remove_member pathlink.com> Jul 23 2005
- Chris Sauls <ibisbasenji gmail.com> Jul 23 2005
- Manfred Nowak <svv1999 hotmail.com> Jul 23 2005
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?
Jul 23 2005
.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
Jul 23 2005
.remove for non associative arrays <.remove_member pathlink.com> wrote: [...]it would make sense if D had buit in way to remove alements from arrays.
And what should the semantics of such an operation look alike? Seems that you are in a need for a complete other data structure than arrays. -manfred
Jul 23 2005









Chris Sauls <ibisbasenji gmail.com> 