next up previous contents index
suivant: Permuted list from its monter: Lists and vectors précédent: Reverse order in a   Table des matières   Index


Reverse a list starting from its n-th element : rotate

rotate takes as argument a list and an integer n (by default n=-1).
rotate rotates the list by n places to the left if n>0 or to the right if n<0. Elements leaving the list from one side come back on the other side. By default n=-1 and the last element becomes first.
Input :
rotate([0,1,2,3,4])
Output :
[4,0,1,2,3]
Input :
rotate([0,1,2,3,4],2)
Output :
[2,3,4,0,1]
Input :
rotate([0,1,2,3,4],-2)
Output :
[3,4,0,1,2]



giac documentation written by Renée De Graeve and Bernard Parisse