Previous Up Next

2.37.9  Permuted list from its n-th element : shift

shift takes as argument a list l and an integer n (by default n=-1).
shift rotates the list to the left if n>0 or to the right if n<0. Elements leaving the list from one side are replaced by undef on the other side.
Input :

shift([0,1,2,3,4])

Output :

[undef,0,1,2,3]

Input :

shift([0,1,2,3,4],2)

Output :

[2,3,4,undef,undef]

Input :

shift([0,1,2,3,4],-2)

Output :

[undef,undef,0,1,2]

Previous Up Next