Plain and simple: how do you copy the contents of the stack into an array in PostScript?
First you need to make an array large enough to hold all the elements, so you need to use count
to find out how many elements there are. Then you need to create an array of that size, and finally you need to put all the elements in the array.
Its not totally obvious to me if you want to leave the stack undisturbed or not, so here's two approaches:
%!
count % Count elements on stack - stack contains <elements...> n
array % Create array of that size - stack contains <elements...> []
astore % Move all elements from stack to array - stack contains [<elements...>]
Now if you want to leave the stack undisturbed:
%!
count % Count elements on stack - stack contains <elements...> n
array % Create array of that size - stack contains <elements...> []
astore % Move all elements from stack to array - stack contains [<elements...>]
aload % Push elements from array to stack - stack contains <elements...> [<elements...>]