Commit fe3b1a0a authored by Peter Billam's avatar Peter Billam

add array and packedarray doc

parent ca9a63c9
<HTML><HEAD><TITLE>PostScript Array Operators
</TITLE>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8" />
<SCRIPT LANGUAGE="JavaScript"> <!--
// -->
</SCRIPT>
</HEAD><BODY BGCOLOR="#FFFFFF">
<CENTER><H2><A NAME="top">PostScript Array Operators
</A></H2>
</CENTER>
<P>
<A NAME="array"></A>
<I>int</I> &nbsp; <B>array</B> &nbsp; =&gt; &nbsp; <I>array</I><BR>
&nbsp; Creates an array of length <I>int</I> initialised with null elements.
The array resides in local or global VM,
according to the current allocation mode.
</P><P>
<A NAME="["></A>
<B>[</B> &nbsp; =&gt; &nbsp; <I>mark</I><BR>
&nbsp; Pushes a mark object onto the stack.
</P><P>
<A NAME="]"></A>
<B>[</B> &nbsp; <I>obj<SUB>0</SUB> . . . obj<SUB>n-1</SUB></I>
&nbsp; <B>]</B> &nbsp; =&gt; &nbsp;
<I>array</I><BR>
&nbsp; Creates a new array of the <I>n</I> elements
since the previous <I>mark</I>.<BR>
&nbsp; The array is in local or global VM,
according to the allocation mode.<BR>
&nbsp; &nbsp; 5 4 3 ] &nbsp; =&gt; &nbsp; % an array with elements 5, 4, 3<BR>
</P><P>
<A NAME="length"></A>
<I>array</I> &nbsp; <B>length</B> &nbsp; =&gt; &nbsp; <I>
int</I><BR>
&nbsp; Returns the number of elements in the array.<BR>
&nbsp; &nbsp; [1 2 4] length &nbsp; =&gt; &nbsp; 3<BR>
&nbsp; &nbsp; [ ] length &nbsp; =&gt; &nbsp; 0<BR>
&nbsp; &nbsp; 20 array length &nbsp;=&gt; &nbsp; 20
</P><P>
<A NAME="get"></A>
<I>array &nbsp; index
</I> &nbsp; <B>get</B> &nbsp; =&gt; &nbsp; <I>
any</I><BR>
&nbsp; Returns a single array-element
identified by its <I>index</I>.<BR>
&nbsp; &nbsp; [31 41 50] 0 get &nbsp; =&gt; &nbsp; 31<BR>
&nbsp; &nbsp; [0 (a mixed-type array) [ ] {add 2 div} ] 2 get &nbsp; =&gt; &nbsp; [ ]<BR>
</P><P>
<A NAME="put"></A>
<I>array &nbsp; index &nbsp; any
</I> &nbsp; <B>put</B> &nbsp; =&gt; &nbsp; -<BR>
&nbsp; Replaces a single element in the array.<BR>
&nbsp; &nbsp; /ar [5 17 3 8] def<BR>
&nbsp; &nbsp; ar 2 (abcd) &nbsp; put<BR>
&nbsp; &nbsp; ar &nbsp; =&gt; &nbsp; [5 17 (abcd) 8]
</P><P>
<A NAME="getinterval"></A>
<I>array &nbsp; index &nbsp; count
</I> &nbsp; <B>getinterval</B> &nbsp; =&gt; &nbsp; <I>subarray</I><BR>
&nbsp; Creates a new array containing
some subsequence of the original elements.<BR>
&nbsp; &nbsp; [9 8 7 6 5] 1 3 &nbsp; getinterval &nbsp; =&gt; &nbsp; [8 7 6]<BR>
</P><P>
<A NAME="putinterval"></A>
<I>array<SUB>1</SUB> &nbsp; index &nbsp; array<SUB>2</SUB>
</I> &nbsp; <B>putinterval</B> &nbsp; =&gt; &nbsp; -<BR>
&nbsp; Replaces a subsequence of the first array
by the contents of the second array.<BR>
&nbsp; &nbsp; /ar [5 8 2 7 3] def<BR>
&nbsp; &nbsp; ar 1 [(a) (b) (c)] &nbsp; putinterval<BR>
&nbsp; &nbsp; ar &nbsp; =&gt; &nbsp; [5 (a) (b) (c) 3]
</P><P>
<A NAME="astore"></A>
<I>any<SUB>0</SUB> . . . any<SUB>n-1</SUB> &nbsp; array
</I> &nbsp; <B>astore</B> &nbsp; =&gt; &nbsp; <I>array</I><BR>
&nbsp; Store the <I>n</I> objects into the <I>array</I>,
where <I>n</I> is the length of the array.<BR>
&nbsp; &nbsp; (a) (bcd) (e) &nbsp; 3 array &nbsp; aload &nbsp; =&gt; &nbsp;
[(a) (bcd) (e)]<BR>
</P><P>
<A NAME="aload"></A>
<I>array</I> &nbsp; <B>aload</B> &nbsp; =&gt; &nbsp;
<I>any<SUB>0</SUB> . . . any<SUB>n-1</SUB> &nbsp; array</I><BR>
&nbsp; Pushes the objects in the <I>array</I> onto the stack,
and then pushes the <I>array</I> itself.<BR>
&nbsp; &nbsp; [23 (ab) -6] &nbsp; aload &nbsp; =&gt; &nbsp;
23 (ab) -6 &nbsp; [23 (ab) -6]<BR>
</P><P>
<A NAME="copy"></A>
<I>array<SUB>1</SUB> array<SUB>2</SUB></I> &nbsp;
<B>copy</B> &nbsp; =&gt; &nbsp;
<I>subarray<SUB>2</SUB></I><BR>
&nbsp; Copies the elements in <I>array<SUB>1</SUB></I> into
<I>array<SUB>2</SUB></I> (which must be long enough)
and pushes the copied subarray.<BR>
&nbsp; Any remaining elements of <I>array<SUB>2</SUB></I>
are not overwritten.<BR>
&nbsp; &nbsp; /a1 &nbsp; [1 2 3] &nbsp; def<BR>
&nbsp; &nbsp; a1 &nbsp; dup length array &nbsp; copy &nbsp; =&gt; &nbsp;
[1 2 3]<BR>
<BR>
&nbsp; &nbsp; /a2 &nbsp; [(a) (b) (c) (d) (e)] &nbsp; def<BR>
&nbsp; &nbsp; a1 &nbsp; a2 &nbsp; copy &nbsp; =&gt; &nbsp; [1 2 3]<BR>
&nbsp; &nbsp; a2 &nbsp; =&gt; &nbsp; [1 2 3 (d) (e)]<BR>
</P><P>
<A NAME="forall"></A>
<I>array &nbsp; proc</I> &nbsp; <B>forall</B> &nbsp; =&gt; &nbsp; -
<BR>
&nbsp; For each object in the <I>array</I>,
it pushes it onto the stack
then executes the <I>proc</I>.<BR>
&nbsp; &nbsp; 0 &nbsp; [13 29 3 -8 21] &nbsp; { add } &nbsp; forall
&nbsp; =&gt; &nbsp; 58
</P><CENTER><P>
Back to
<A HREF="index.html">index.html</A>
</P><CENTER></BODY></HTML>
......@@ -80,28 +80,50 @@ srand</A>
rrand</A>
<BR>
<B>Array&nbsp;Operators</B> &nbsp;
array
[
]
length
get put
getinterval
putinterval
astore
aload
copy
forall
<A HREF="array_ops.html#array">
array</A> &nbsp;
<A HREF="array_ops.html#[">
[</A> &nbsp;
<A HREF="array_ops.html#]">
]</A> &nbsp;
<A HREF="array_ops.html#length">
length</A>
<A HREF="array_ops.html#get">
get</A>
<A HREF="array_ops.html#put">
put</A>
<A HREF="array_ops.html#getinterval">
getinterval</A>
<A HREF="array_ops.html#putinterval">
putinterval</A>
<A HREF="array_ops.html#astore">
astore</A>
<A HREF="array_ops.html#aload">
aload</A>
<A HREF="array_ops.html#copy">
copy</A>
<A HREF="array_ops.html#forall">
forall</A>
<BR>
<B>Packed&nbsp;Array&nbsp;Operators</B> &nbsp;
packedarray
currentpacking
setpacking
length
get
getinterval
aload
copy
forall
<A HREF="packed_ops.html#packedarray">
packedarray</A>
<A HREF="packed_ops.html#currentpacking">
currentpacking</A>
<A HREF="packed_ops.html#setpacking">
setpacking</A>
<A HREF="packed_ops.html#length">
length</A>
<A HREF="packed_ops.html#get">
get</A>
<A HREF="packed_ops.html#getinterval">
getinterval</A>
<A HREF="packed_ops.html#aload">
aload</A>
<A HREF="packed_ops.html#copy">
copy</A>
<A HREF="packed_ops.html#forall">
forall</A>
<BR>
<B>Dictionary&nbsp;Operators</B> &nbsp;
dict
......
<HTML><HEAD><TITLE>PostScript Packed Array Operators
</TITLE>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8" />
<SCRIPT LANGUAGE="JavaScript"> <!--
// -->
</SCRIPT>
</HEAD><BODY BGCOLOR="#FFFFFF">
<CENTER><H2><A NAME="top">PostScript Packed Array Operators
</A></H2>
</CENTER>
<P>
Packed arrays are mostly used to store procedures.<BR>
They are more compact than ordinary arrays, and sequential access
(as in procedure exection or with <I>forall</I>) is very fast.<BR>
On the other hand, they are read-only,
and random access (as with <I>get</I>) is slower.
</P><P>
<A NAME="packedarray"></A>
<I>any<SUB>0</SUB> . . . any<SUB>n-1</SUB> &nbsp; n</I>
&nbsp; <B>packedarray</B> &nbsp; =&gt; &nbsp; <I>packedarray</I><BR>
&nbsp; Creates a packedarray of length <I>n</I> with elements
<I>any<SUB>0</SUB></I> to <I>any<SUB>n-1</SUB></I>
</P><P>
<A NAME="currentpacking"></A>
<B>currentpacking</B> &nbsp; =&gt; &nbsp; <I>bool</I><BR>
&nbsp; Returns the array packing mode currently in effect.<BR>
&nbsp; &nbsp; /savepackingmode currentpacking def<BR>
</P><P>
<A NAME="setpacking"></A>
<I>bool</I> &nbsp; <B>setpacking</B> &nbsp; =&gt; &nbsp; -<BR>
&nbsp; The packing mode affects only the creation of procedures by the<BR>
&nbsp; program-scanner when it encounters text braketed by { and }<BR>
&nbsp; The value <I>true</I> creates packed arrays;
<I>false</I> creates ordinary arrays.<BR>
&nbsp; The default is <I>false</I>.<BR>
&nbsp; &nbsp; true setpacking<BR>
&nbsp; &nbsp; /myproc { blurb blurb } def<BR>
&nbsp; &nbsp; savepackingmode setpacking
</P><P>
<A NAME="length"></A>
<I>packedarray</I> &nbsp; <B>length</B> &nbsp; =&gt; &nbsp; <I>
int</I><BR>
&nbsp; Returns the number of elements in the packedarray.<BR>
</P><P>
<A NAME="get"></A>
<I>packedarray &nbsp; index
</I> &nbsp; <B>get</B> &nbsp; =&gt; &nbsp; <I>
any</I><BR>
&nbsp; Returns a single packedarray-element
identified by its <I>index</I>.
</P><P>
<A NAME="getinterval"></A>
<I>packedarray &nbsp; index &nbsp; count
</I> &nbsp; <B>getinterval</B> &nbsp; =&gt; &nbsp; <I>subarray</I><BR>
&nbsp; Creates a new array containing <I>count</I> elements
of the original <I>packedarray</I>, starting at <I>index</I>.
</P><P>
<A NAME="aload"></A>
<I>packedarray</I> &nbsp; <B>aload</B> &nbsp; =&gt; &nbsp;
<I>any<SUB>0</SUB> . . . any<SUB>n-1</SUB> &nbsp; packedarray</I><BR>
&nbsp; Pushes the objects in the <I>packedarray</I> onto the stack,
and then pushes the <I>packedarray</I> itself.
</P><P>
<A NAME="copy"></A>
<I>packedarray array</I> &nbsp;
<B>copy</B> &nbsp; =&gt; &nbsp;
<I>subarray</I><BR>
&nbsp; Copies the elements in <I>packedarray</I> into
<I>array</I> (which must be long enough)
and pushes the copied subarray.<BR>
&nbsp; Any remaining elements of <I>array</I>
are not overwritten.<BR>
</P><P>
<A NAME="forall"></A>
<I>packedarray &nbsp; proc</I> &nbsp; <B>forall</B> &nbsp; =&gt; &nbsp; -
<BR>
&nbsp; For each object in the <I>packedarray</I>,
it pushes it onto the stack
then executes the <I>proc</I>.
</P><CENTER><P>
Back to
<A HREF="index.html">index.html</A>
</P><CENTER></BODY></HTML>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment