5.3.16 Shifting the elements of a list
The shift command
shifts the elements of a list.
-
shift takes one mandatory argument and one optional
argument:
-
L, a list.
- Optionally, n, an integer (by default n=−1).
- shift(L) returns the list formed by shifting the
elements of L n places to the left if n>0 or −n places to the right
if n<0. Elements leaving the list from one side are replaced by zeros
on the other side.
Examples