How are 2D arrays created in postscript?
I'm thinking that I need an array where every element is an array, the array in this case is called shape.
/shape 2 array def
/shape_length 3 def
shape 0 2 array put
shape 1 2 array put
shape 2 2 array put
% [[null, null, null], [null, null, null], [null, null, null]]
I could create a loop instead of copying a line 3 times like this.
I may not otherwise need shape_length.
Is this a good way to go about doing this or is there something more succinct?
The creation of such a structure can indeed be done very concisely:
[3{3 array}repeat]
Using Ghostscript interactively, you can see that it actually results in the desired array:
GS>[3{3 array}repeat]==
[[null null null] [null null null] [null null null]]