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

281 lines
No EOL
5.5 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>copy-seq | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_copy-seq.html"
><LINK REL="next" HREF="f_elt.html" TYPE="text/html" TITLE="elt"
><LINK REL="prev" HREF="t_sequence.html" TYPE="text/html" TITLE="sequence"
><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_copy-seq.html"
>copy-seq</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="t_sequence.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_elt.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="copy-seq"
></SPAN
><B
>copy-seq</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
>copy-seq</B
> <SPAN CLASS="cmssi"
>sequence</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmssi"
>copied-sequence</SPAN
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><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
><P CLASS="j"
><VAR CLASS="param"
>copied-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"
>Creates a copy of <VAR CLASS="param"
>sequence</VAR
>. The <A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>elements</EM
></A
> of the new <A HREF="26_1_Glossary.html#sequence"
><EM CLASS="term"
>sequence</EM
></A
> are the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> as the corresponding <A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>elements</EM
></A
> of the given <VAR CLASS="param"
>sequence</VAR
>. </P
><P CLASS="j"
>If <VAR CLASS="param"
>sequence</VAR
> is a <A HREF="26_1_Glossary.html#vector"
><EM CLASS="term"
>vector</EM
></A
>, the result is a <A HREF="26_1_Glossary.html#fresh"
><EM CLASS="term"
>fresh</EM
></A
> <A HREF="26_1_Glossary.html#simple_array"
><EM CLASS="term"
>simple array</EM
></A
> of <A HREF="26_1_Glossary.html#rank"
><EM CLASS="term"
>rank</EM
></A
> one that has the same <A HREF="26_1_Glossary.html#actual_array_element_type"
><EM CLASS="term"
>actual array element type</EM
></A
> as <VAR CLASS="param"
>sequence</VAR
>. If <VAR CLASS="param"
>sequence</VAR
> is a <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
>, the result is a <A HREF="26_1_Glossary.html#fresh"
><EM CLASS="term"
>fresh</EM
></A
> <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
>.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
>(setq str "a string") <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> "a string"
(equalp str (copy-seq str)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(eql str (copy-seq str)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
></PRE
></DD
><DT
><B
>Exceptional Situations</B
></DT
><DD
><P CLASS="j"
>Should be prepared to signal 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
> if <VAR CLASS="param"
>sequence</VAR
> is not a <A HREF="26_1_Glossary.html#proper_sequence"
><EM CLASS="term"
>proper sequence</EM
></A
>.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_copy-list.html" CLASS="funref"
><B
>copy-list</B
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><P CLASS="j"
>From a functional standpoint,</P
><PRE CLASS="screen"
>(copy-seq x) <SPAN CLASS="cmsy"
><SPAN STYLE="font-size:16px;vertical-align:-2px"
>&#8801;</SPAN
></SPAN
> (subseq x 0)</PRE
><P CLASS="j"
>However, the programmer intent is typically very different in these two cases.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="t_sequence.html" CLASS="prev"
>&#8592;</A
><A HREF="f_elt.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
>