shift<T> function
adds the elem
to the end of l
.
if n is given the first element is popped,
if the list is longer than n
Implementation
void shift<T>(List<T> l, T elem, [int? n]) {
l.add(elem);
if (n != null && l.length > n) l.removeAt(0);
}