Logo

Programming-Idioms

  • Smalltalk
  • Dart

Idiom #291 Remove sublist

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

items.removeRange(i, j);
items = [items(:,i-1), items(j:)]

items needs to be an allocatable array. It is reallocated on assignment to a constructor containing the elements from the start of the array to i-1 and from j to the end.

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