Logo

Programming-Idioms

  • C++
  • Erlang
  • Obj-c

Idiom #29 Remove item from list, by its index

Remove i-th item from list items.
This will alter the original list or return a new list, depending on which is more idiomatic.
Note that in most languages, the smallest valid value for i is 0.

@import Foundation;
[items removeObjectAtIndex:i];

Alters the original
items.erase (items.begin () + i);
{Left, [_|Right]} = lists:split(I-1, Items),
Left ++ Right.
with Ada.Containers.Vectors;
use Ada.Containers;
Items.Delete (I);

New implementation...