1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/f_concat.htm

69 lines
6.2 KiB
HTML
Raw Normal View History

2024-04-01 10:24:07 +02:00
<!-- 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 CONCATENATE</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_sbs_s.htm">
<LINK REL=UP HREF="c_sequen.htm">
<LINK REL=NEXT HREF="f_merge.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_sbs_s.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_sequen.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_merge.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="concatenate"><I>Function</I> <B>CONCATENATE</B></A> <P>
<P><B>Syntax:</B><P>
<P>
<B>concatenate</B> <I>result-type <TT>&amp;rest</TT> sequences</I> =&gt; <I>result-sequence</I><P>
<P>
<P><B>Arguments and Values:</B><P>
<P>
<I>result-type</I>---a <A REL=DEFINITION HREF="t_seq.htm#sequence"><B>sequence</B></A> <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A>. <P>
<I>sequences</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></A>. <P>
<I>result-sequence</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#proper_sequence"><I>proper sequence</I></A> of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <I>result-type</I>. <P>
<P><B>Description:</B><P>
<P>
<A REL=DEFINITION HREF="#concatenate"><B>concatenate</B></A> returns a <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></A> that contains all the individual elements of all the <I>sequences</I> in the order that they are supplied. The <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></A> is of type <I>result-type</I>, which must be a <A REL=DEFINITION HREF="26_glo_s.htm#subtype"><I>subtype</I></A> of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="t_seq.htm#sequence"><B>sequence</B></A>. <P>
All of the <I>sequences</I> are copied from; the result does not share any structure with any of the <I>sequences</I>. Therefore, if only one <I>sequence</I> is provided and it is of type <I>result-type</I>, <A REL=DEFINITION HREF="#concatenate"><B>concatenate</B></A> is required to copy <I>sequence</I> rather than simply returning it. <P>
It is an error if any element of the <I>sequences</I> cannot be an element of the <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></A> result. If the <I>result-type</I> is a <A REL=DEFINITION HREF="26_glo_s.htm#subtype"><I>subtype</I></A> of <A REL=DEFINITION HREF="t_list.htm#list"><B>list</B></A>, the result will be a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A>. <P>
If the <I>result-type</I> is a <A REL=DEFINITION HREF="26_glo_s.htm#subtype"><I>subtype</I></A> of <A REL=DEFINITION HREF="t_vector.htm#vector"><B>vector</B></A>, then if the implementation can determine the element type specified for the <I>result-type</I>, the element type of the resulting array is the result of <I>upgrading</I> that element type; or, if the implementation can determine that the element type is unspecified (or <TT>*</TT>), the element type of the resulting array is <A REL=DEFINITION HREF="t_t.htm#t"><B>t</B></A>; otherwise, an error is signaled. <P>
<P><B>Examples:</B><P>
<P>
<PRE>
(concatenate 'string &quot;all&quot; &quot; &quot; &quot;together&quot; &quot; &quot; &quot;now&quot;) =&gt; &quot;all together now&quot;
(concatenate 'list &quot;ABC&quot; '(d e f) #(1 2 3) #*1011)
=&gt; (#\A #\B #\C D E F 1 2 3 1 0 1 1)
(concatenate 'list) =&gt; NIL
</PRE>
</TT> <P>
<PRE>
(concatenate '(vector * 2) &quot;a&quot; &quot;bc&quot;) should signal an error
</PRE>
</TT> <P>
<P><B>Affected By:</B> None.
<P>
<P><B>Exceptional Situations:</B><P>
<P>
An error is signaled if the <I>result-type</I> is neither a <A REL=DEFINITION HREF="26_glo_r.htm#recognizable_subtype"><I>recognizable subtype</I></A> of <A REL=DEFINITION HREF="t_list.htm#list"><B>list</B></A>, nor a <A REL=DEFINITION HREF="26_glo_r.htm#recognizable_subtype"><I>recognizable subtype</I></A> of <A REL=DEFINITION HREF="t_vector.htm#vector"><B>vector</B></A>. <P>
An error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> should be signaled if <I>result-type</I> specifies the number of elements and the sum of <I>sequences</I> is different from that number. <P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="f_append.htm#append"><B>append</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/iss302.htm">SEQUENCE-TYPE-LENGTH:MUST-MATCH</A><LI> <A REL=CHILD HREF="../Issues/iss073.htm">CONCATENATE-SEQUENCE:SIGNAL-ERROR</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>