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

76 lines
6.3 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 MAKE-SEQUENCE</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_fill.htm">
<LINK REL=UP HREF="c_sequen.htm">
<LINK REL=NEXT HREF="f_subseq.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_fill.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_subseq.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="make-sequence"><I>Function</I> <B>MAKE-SEQUENCE</B></A> <P>
<P><B>Syntax:</B><P>
<P>
<B>make-sequence</B> <I>result-type size <TT>&amp;key</TT> initial-element</I> =&gt; <I>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>size</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>. <P>
<I>initial-element</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. The default is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A>. <P>
<I>sequence</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#proper_sequence"><I>proper sequence</I></A>. <P>
<P><B>Description:</B><P>
<P>
Returns a <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></A> of the type <I>result-type</I> and of length <I>size</I>, each of the <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> of which has been initialized to <I>initial-element</I>. <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_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>
(make-sequence 'list 0) =&gt; ()
(make-sequence 'string 26 :initial-element #\.)
=&gt; &quot;..........................&quot;
(make-sequence '(vector double-float) 2
:initial-element 1d0)
=&gt; #(1.0d0 1.0d0)
</PRE>
</TT> <P>
<PRE>
(make-sequence '(vector * 2) 3) should signal an error
(make-sequence '(vector * 4) 3) should signal an error
</PRE>
</TT> <P>
<P><B>Affected By:</B><P>
<P>
The <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A>. <P>
<P><B>Exceptional Situations:</B><P>
<P>
The consequences are unspecified if <I>initial-element</I> is not an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> which can be stored in the resulting <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></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> must be 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 <I>size</I> is different from that number. <P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="f_mk_ar.htm#make-array"><B>make-array</B></A>, <A REL=DEFINITION HREF="f_mk_lis.htm#make-list"><B>make-list</B></A> <P>
<P><B>Notes:</B><P>
<PRE>
(make-sequence 'string 5) == (make-string 5)
</PRE>
</TT> <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/iss045.htm">CHARACTER-PROPOSAL:2-6-5</A><LI> <A REL=CHILD HREF="../Issues/iss302.htm">SEQUENCE-TYPE-LENGTH:MUST-MATCH</A><LI> <A REL=CHILD HREF="../Issues/iss013.htm">ARGUMENTS-UNDERSPECIFIED:SPECIFY</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>