| Refresh | Home EGTry.com

stack roll operator


n j roll. reorder the top n elements of stack. shift all n elements by j time.

stack roll operation

stack before operation stack after comment
1 2 3 4 5 2 1 roll 1 2 3 5 4 same as exch
1 2 3 4 5 3 1 roll 1 2 5 3 4 put the top element and insert at some position
1 2 3 4 5 count 1 roll 5 1 2 3 4 put the top element at the bottom
1 2 3 4 5 4 -1 roll 1 5 2 3 4 take an element from middle and put at top position