removeRepeated<T> static method
Removes subsequent equal items from a list
.
Implementation
static List<T> removeRepeated<T>(List<T> list) {
List<T> newList = [];
for (int i = 1; i < list.length; i++) {
if (list[i - 1] != list[i]) {
newList.add(list[i - 1]);
}
}
if (newList.last != list.last) {
newList.add(list.last);
}
return newList;
}