1
0
Fork 0
cl-sites/novaspec.org/cl/f_make-sequence.html
2025-02-05 18:52:26 +01:00

353 lines
No EOL
7.3 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>make-sequence | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_make-sequence.html"
><LINK REL="next" HREF="f_subseq.html" TYPE="text/html" TITLE="subseq"
><LINK REL="prev" HREF="f_fill.html" TYPE="text/html" TITLE="fill"
><LINK REL="up" HREF="17_3_Sequences_Dictionary.html" TYPE="text/html" TITLE="17.3 Sequences Dictionary"
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
><SCRIPT SRC="dpans.js%3F3909942064"
></SCRIPT
><SCRIPT SRC="apropos.js%3F3909942064"
></SCRIPT
></HEAD
><BODY
><DIV
><DIV CLASS="topnav"
><DIV CLASS="breadcrumb"
><SPAN CLASS="breadcrumb-item"
><A HREF="index.html"
>Common Lisp Nova Spec</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="17_Sequences.html"
>17. Sequences</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="17_3_Sequences_Dictionary.html"
>17.3 Sequences Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="f_make-sequence.html"
>make-sequence</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_fill.html" CLASS="prev"
>&#8592;</A
><SPAN ID="apropos-label"
>Apropos </SPAN
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
><A HREF="f_subseq.html" CLASS="next"
>&#8594;</A
></DIV
><DIV ID="apropos-res"
></DIV
></DIV
></DIV
><DIV CLASS="matter"
><DIV CLASS="com"
><DIV CLASS="begincom"
><HR
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="make-sequence"
></SPAN
><B
>make-sequence</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Function</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><P CLASS="j"
><B
>make-sequence</B
> <SPAN CLASS="cmssi"
>result-type</SPAN
> <SPAN CLASS="cmssi"
>size</SPAN
> <SPAN CLASS="cmtt"
>&amp;key</SPAN
> <SPAN CLASS="cmssi"
>initial-element</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmssi"
>sequence</SPAN
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>result-type</VAR
> &#8212; a <A HREF="t_sequence.html" CLASS="typeref"
><B
>sequence</B
></A
> <A HREF="26_1_Glossary.html#type_specifier"
><EM CLASS="term"
>type specifier</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>size</VAR
> &#8212; a non-negative <A HREF="26_1_Glossary.html#integer"
><EM CLASS="term"
>integer</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>initial-element</VAR
> &#8212; an <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
>. The default is <A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>sequence</VAR
> &#8212; a <A HREF="26_1_Glossary.html#proper_sequence"
><EM CLASS="term"
>proper sequence</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
>Returns a <A HREF="26_1_Glossary.html#sequence"
><EM CLASS="term"
>sequence</EM
></A
> of the type <VAR CLASS="param"
>result-type</VAR
> and of length <VAR CLASS="param"
>size</VAR
>, each of the <A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>elements</EM
></A
> of which has been initialized to <VAR CLASS="param"
>initial-element</VAR
>. </P
><P CLASS="j"
>If the <VAR CLASS="param"
>result-type</VAR
> is a <A HREF="26_1_Glossary.html#subtype"
><EM CLASS="term"
>subtype</EM
></A
> of <A HREF="t_list.html" CLASS="typeref"
><B
>list</B
></A
>, the result will be a <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
>. </P
><P CLASS="j"
>If the <VAR CLASS="param"
>result-type</VAR
> is a <A HREF="26_1_Glossary.html#subtype"
><EM CLASS="term"
>subtype</EM
></A
> of <A HREF="t_vector.html" CLASS="typeref"
><B
>vector</B
></A
>, then if the implementation can determine the element type specified for the <VAR CLASS="param"
>result-type</VAR
>, the element type of the resulting array is the result of <A HREF="26_1_Glossary.html#upgrade"
><EM CLASS="term"
>upgrading</EM
></A
> that element type; or, if the implementation can determine that the element type is unspecified (or <CODE CLASS="f"
>*</CODE
>), the element type of the resulting array is <A HREF="t_t.html" CLASS="typeref"
><B
>t</B
></A
>; otherwise, an error is signaled.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
> (make-sequence 'list 0) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> ()
(make-sequence 'string 26 :initial-element #\.)
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> ".........................."
(make-sequence '(vector double-float) 2
:initial-element 1d0)
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> #(1.0d0 1.0d0)</PRE
><PRE CLASS="screen"
>(make-sequence '(vector * 2) 3) should signal an error
(make-sequence '(vector * 4) 3) should signal an error</PRE
></DD
><DT
><B
>Affected By</B
></DT
><DD
><P CLASS="j"
>The <A HREF="26_1_Glossary.html#implementation"
><EM CLASS="term"
>implementation</EM
></A
>.</P
></DD
><DT
><B
>Exceptional Situations</B
></DT
><DD
><P CLASS="j"
>The consequences are unspecified if <VAR CLASS="param"
>initial-element</VAR
> is not an <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
> which can be stored in the resulting <A HREF="26_1_Glossary.html#sequence"
><EM CLASS="term"
>sequence</EM
></A
>. </P
><P CLASS="j"
>An error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_type-error.html" CLASS="typeref"
><B
>type-error</B
></A
> must be signaled if the <VAR CLASS="param"
>result-type</VAR
> is neither a <A HREF="26_1_Glossary.html#recognizable_subtype"
><EM CLASS="term"
>recognizable subtype</EM
></A
> of <A HREF="t_list.html" CLASS="typeref"
><B
>list</B
></A
>, nor a <A HREF="26_1_Glossary.html#recognizable_subtype"
><EM CLASS="term"
>recognizable subtype</EM
></A
> of <A HREF="t_vector.html" CLASS="typeref"
><B
>vector</B
></A
>. </P
><P CLASS="j"
>An error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_type-error.html" CLASS="typeref"
><B
>type-error</B
></A
> should be signaled if <VAR CLASS="param"
>result-type</VAR
> specifies the number of elements and <VAR CLASS="param"
>size</VAR
> is different from that number.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_make-array.html" CLASS="funref"
><B
>make-array</B
></A
>, <A HREF="f_make-list.html" CLASS="funref"
><B
>make-list</B
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><PRE CLASS="screen"
>(make-sequence 'string 5) <SPAN CLASS="cmsy"
><SPAN STYLE="font-size:16px;vertical-align:-2px"
>&#8801;</SPAN
></SPAN
> (make-string 5)</PRE
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_fill.html" CLASS="prev"
>&#8592;</A
><A HREF="f_subseq.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>