On Sunday 24 October 2010 04:24:07 Adam Cigánek wrote: > remove removes element at a given offset. I want to remove element > with a given value. This is example shows it better: > > auto a = ["foo", "bar", "baz"]; > auto b = delete(a, "bar"); > > assert(["foo", "baz"] == b); > > > adam. > > 2010/10/24 Simen kjaeraas <simen.kja...@gmail.com>: > > On Sun, 24 Oct 2010 13:02:24 +0200, Adam Cigánek <adam.ciga...@gmail.com> > > > > wrote: > >> Hello, > >> > >> Is there a function in the standard library to delete an element from > >> an array (or range)? Something like: > >> > >> auto a = [1, 2, 3, 4, 5, 6]; > >> auto b = delete(a, 4); > >> > >> assert([1, 2, 3, 4, 6] == b); > >> > >> I've noticed there is eliminate in std.algorithm, which seems to be > >> doing just that, but it's commented out. > >> > >> It's not difficult to roll my own, (with the help of indexOf and > >> remove), but I thought that this is pretty common operation so it > >> should be in the standard library. > > > > std.algorithm has remove, which does what you want. > > > > -- > > Simen
Well, then use indexOf() to get the offset and remove() to remove the element. - Jonathan M Davis