89 lines
5.5 KiB
HTML
89 lines
5.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: Function NCONC</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="f_null.htm">
|
|
<LINK REL=UP HREF="c_conses.htm">
|
|
<LINK REL=NEXT HREF="f_append.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="f_null.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_conses.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_append.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="nconc"><I>Function</I> <B>NCONC</B></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>nconc</B> <I><TT>&rest</TT> lists</I> => <I>concatenated-list</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>list</I>---each but the last must be a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> (which might be a <I>dotted list</I> but must not be a <A REL=DEFINITION HREF="26_glo_c.htm#circular_list"><I>circular list</I></A>); the last <I>list</I> may be any <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. <P>
|
|
<I>concatenated-list</I>---a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
Returns a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> that is the concatenation of <I>lists</I>. If no <I>lists</I> are supplied, <TT>(nconc)</TT> returns <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <A REL=DEFINITION HREF="#nconc"><B>nconc</B></A> is defined using the following recursive relationship: <P>
|
|
<PRE>
|
|
(nconc) => ()
|
|
(nconc nil . lists) == (nconc . lists)
|
|
(nconc list) => list
|
|
(nconc list-1 list-2) == (progn (rplacd (last list-1) list-2) list-1)
|
|
(nconc list-1 list-2 . lists) == (nconc (nconc list-1 list-2) . lists)
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(nconc) => NIL
|
|
(setq x '(a b c)) => (A B C)
|
|
(setq y '(d e f)) => (D E F)
|
|
(nconc x y) => (A B C D E F)
|
|
x => (A B C D E F)
|
|
</PRE>
|
|
</TT> Note, in the example, that the value of <TT>x</TT> is now different, since its last <A REL=DEFINITION HREF="26_glo_c.htm#cons"><I>cons</I></A> has been <A REL=DEFINITION HREF="f_rplaca.htm#rplacd"><B>rplacd</B></A>'d to the value of <TT>y</TT>. If <TT>(nconc x y)</TT> were evaluated again, it would yield a piece of a <A REL=DEFINITION HREF="26_glo_c.htm#circular_list"><I>circular list</I></A>, whose printed representation would be <TT>(A B C D E F D E F D E F ...)</TT>, repeating forever; if the <A REL=DEFINITION HREF="v_pr_cir.htm#STprint-circleST"><B>*print-circle*</B></A> switch were <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A>, it would be printed as <TT>(A B C . #1=(D E F . #1#))</TT>. <P>
|
|
|
|
<PRE>
|
|
(setq foo (list 'a 'b 'c 'd 'e)
|
|
bar (list 'f 'g 'h 'i 'j)
|
|
baz (list 'k 'l 'm)) => (K L M)
|
|
(setq foo (nconc foo bar baz)) => (A B C D E F G H I J K L M)
|
|
foo => (A B C D E F G H I J K L M)
|
|
bar => (F G H I J K L M)
|
|
baz => (K L M)
|
|
|
|
(setq foo (list 'a 'b 'c 'd 'e)
|
|
bar (list 'f 'g 'h 'i 'j)
|
|
baz (list 'k 'l 'm)) => (K L M)
|
|
(setq foo (nconc nil foo bar nil baz)) => (A B C D E F G H I J K L M)
|
|
foo => (A B C D E F G H I J K L M)
|
|
bar => (F G H I J K L M)
|
|
baz => (K L M)
|
|
</PRE>
|
|
</TT> <P>
|
|
<P>
|
|
<P><B>Side Effects:</B><P>
|
|
<P>
|
|
The <I>lists</I> are modified rather than copied. <P>
|
|
<P><B>Affected By:</B> None.
|
|
<P>
|
|
<P><B>Exceptional Situations:</B> None.
|
|
<P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_append.htm#append"><B>append</B></A>, <A REL=DEFINITION HREF="f_concat.htm#concatenate"><B>concatenate</B></A> <P>
|
|
<P><B>Notes:</B> None.
|
|
<P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss293.htm">REMF-DESTRUCTION-UNSPECIFIED:X3J13-MAR-89</A><LI> <A REL=CHILD HREF="../Issues/iss138.htm">DOTTED-LIST-ARGUMENTS: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>
|