Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #291 Remove sublist

Delete all the elements from index i (included) to index j (excluded) from the list items.

items[i:j] = []
del items[i:j]
items.removeRange(i, j);
items = [items(:,i-1), items(j:)]
import "slices"
items = slices.Delete(items, i, j)
items = append(items[:i], items[j:]...)
copy(items[i:], items[j:])
for k, n := len(items)-j+i, len(items); k < n; k++ {
	items[k] = nil
}
items = items[:len(items)-j+i]
items.removeAll(items.subList(i, j));
local function erase(t,i,j)
 for i=1,j-1 do
  t[i]=nil
 end
end
erase(items,i,j)
for index := j-1 downto i do
  items.delete(index);
splice @items, $i, ($j - $i);
items.slice!(i...j)
items.drain(i..j)

New implementation...
< >
programming-idioms.org