POSTSCRIPT EXERCISES




For Questions 1-5, assume that the stack is initially empty, and give the
contents of the stack after the given PostScript program is executed.

 1.   1 dup add dup add dup add dup add

      [Note: "dup" copies the top most element of the stack.]

 2.   1 dup mul dup mul dup mul dup mul

 3.   2 dup mul dup mul dup mul dup mul

 4.   1 1 2 copy add 2 copy add 2 copy add 2 copy add

      [Note: "copy" pops an integer N off the stack, then copies the N
       integers at the top of the stack. "1 copy" is the same as "dup".]

 5.   1 1 10 { 2 copy add } repeat

      [Note: "N {...} repeat" executes the grouped sequence N times.]

 6. What does the following Postscript program do?

       %!
       200 200 moveto 
       100 100 rlineto 
       200 300 moveto 
       100 -100 rlineto
       stroke showpage

 7. What does the following Postscript program do?

       %!
       100 -100 200 300 100 100 200 200
       moveto rlineto moveto rlineto
       stroke showpage

 8. What does the following Postscript program do?

       %!
       200 200 moveto 300 300 lineto 200 300 moveto 300 200 lineto
       stroke showpage

 9. Write a Postscript program to draw a "T".