1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/22_ach.htm
2024-04-01 10:24:07 +02:00

40 lines
6.5 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 22.1.3.8</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="22_acg.htm">
<LINK REL=UP HREF="22_ac.htm">
<LINK REL=NEXT HREF="22_aci.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="22_acg.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="22_ac.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="22_aci.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
22.1.3.8 Printing Other Arrays</H2> <P>
If <A REL=DEFINITION HREF="v_pr_ar.htm#STprint-arrayST"><B>*print-array*</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> and <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, any <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A> other than a <A REL=DEFINITION HREF="26_glo_v.htm#vector"><I>vector</I></A> is printed using <TT>#</TT><TT>n</TT><TT>A</TT> format. Let <TT>n</TT> be the <A REL=DEFINITION HREF="26_glo_r.htm#rank"><I>rank</I></A> of the <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A>. Then <TT>#</TT> is printed, then <TT>n</TT> as a decimal integer, then <TT>A</TT>, then <TT>n</TT> open parentheses. Next the <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> are scanned in row-major order, using <A REL=DEFINITION HREF="f_wr_pr.htm#write"><B>write</B></A> on each <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A>, and separating <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> from each other with <A REL=DEFINITION HREF="26_glo_w.htm#whitespace"><I>whitespace</I></A>[1]. The array's dimensions are numbered 0 to <TT>n</TT>-1 from left to right, and are enumerated with the rightmost index changing fastest. Every time the index for dimension <TT>j</TT> is incremented, the following actions are taken: <P>
<P><DL><DT>* If <TT>j</TT> &lt; <TT>n</TT>-1, then a close parenthesis is printed. <P><DD>
<DT>* If incrementing the index for dimension <TT>j</TT> caused it to equal dimension <TT>j</TT>, that index is reset to zero and the index for dimension <TT>j</TT>-1 is incremented (thereby performing these three steps recursively), unless <TT>j</TT>=0, in which case the entire algorithm is terminated. If incrementing the index for dimension <TT>j</TT> did not cause it to equal dimension <TT>j</TT>, then a space is printed. <P><DD>
<DT>* If <TT>j</TT> &lt; <TT>n</TT>-1, then an open parenthesis is printed. <P><DD></DL><P>
This causes the contents to be printed in a format suitable for <TT>:initial-contents</TT> to <A REL=DEFINITION HREF="f_mk_ar.htm#make-array"><B>make-array</B></A>. The lists effectively printed by this procedure are subject to truncation by <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-levelST"><B>*print-level*</B></A> and <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-lengthST"><B>*print-length*</B></A>. <P>
If the <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A> is of a specialized <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A>, containing bits or characters, then the innermost lists generated by the algorithm given above can instead be printed using bit-vector or string syntax, provided that these innermost lists would not be subject to truncation by <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-lengthST"><B>*print-length*</B></A>. <P>
If both <A REL=DEFINITION HREF="v_pr_ar.htm#STprint-arrayST"><B>*print-array*</B></A> and <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A> are <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, then the <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A> is printed in a format (using <TT>#&lt;</TT>) that is concise but not readable. <P>
If <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, the <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A> prints in an <A REL=DEFINITION HREF="26_glo_i.htm#implementation-defined"><I>implementation-defined</I></A> manner; see the <A REL=DEFINITION HREF="26_glo_v.htm#variable"><I>variable</I></A> <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A>. In particular, this may be important for arrays having some dimension <TT>0</TT>. <P>
For information on how the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> parses these ``other <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>arrays</I></A>,'' see <A REL=CHILD HREF="02_dhl.htm">Section 2.4.8.12 (Sharpsign A)</A>. <P>
<A REL=CHILD HREF="22_aci.htm"><H2>
22.1.3.9 Examples of Printing Arrays</H2></A><P><P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss276.htm">PRINT-READABLY-BEHAVIOR:CLARIFY</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>