delete an element from an array

Simen kjaeraas simen.kjaras at gmail.com
Sun Oct 24 04:08:28 PDT 2010


On Sun, 24 Oct 2010 13:02:24 +0200, Adam Cigánek <adam.ciganek at 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


More information about the Digitalmars-d-learn mailing list