How Roll Works

5.5.1 How Roll Works

This example should make the use of "roll" quite clear. First we add some objects to the stack:
GS>4
GS<1>3
GS<2>2
GS<3>1
GS<4>stack
1
2
3
4
Now we roll the top 3 by 1 position:
GS<4>3 1 roll
GS<4>stack
2
3
1
4
We can go back by rolling -1 position:
GS<4>3 -1 roll
GS<4>stack
1
2
3
4
Also, we can roll the top four by 2 slots:
GS<4>4 2 roll
GS<4>stack
3
4
1
2

David Maxwell, who is still writing this, would like to hear your comments and suggestions. And remember, parts of this manual are based on P.J. Weingartner's work: A First Guide to PostScript.