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.slice!(i...j)
items.removeRange(i, j);
items = [items(:,i-1), 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 = append(items[:i], items[j:]...)
import "slices"
items = slices.Delete(items, i, j)
import java.util.ArrayList;
for(int index = i; index < j; index++) {
	items.remove(index);
}
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[i:j] = []
del items[i:j]
items.drain(i..j)

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