1
0
Fork 0
cl-sites/novaspec.org/cl/f_rest.html

273 lines
5 KiB
HTML
Raw Normal View History

2025-02-05 18:52:26 +01:00
<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>rest | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_rest.html"
><LINK REL="next" HREF="f_member.html" TYPE="text/html" TITLE="member, member-if, member-if-not"
><LINK REL="prev" HREF="f_nthcdr.html" TYPE="text/html" TITLE="nthcdr"
><LINK REL="up" HREF="14_2_Conses_Dictionary.html" TYPE="text/html" TITLE="14.2 Conses 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="14_Conses.html"
>14. Conses</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="14_2_Conses_Dictionary.html"
>14.2 Conses Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="f_rest.html"
>rest</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_nthcdr.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_member.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="rest"
></SPAN
><B
>rest</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Accessor</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><P CLASS="j"
><B
>rest</B
> <SPAN CLASS="cmssi"
>list</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmssi"
>tail</SPAN
></P
><P CLASS="j"
><B
>(setf (rest</B
> <SPAN CLASS="cmssi"
>list</SPAN
><B
>)</B
> <SPAN CLASS="cmssi"
>new-tail</SPAN
><B
>)</B
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>list</VAR
> &#8212; a <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
>, which might be a <A HREF="26_1_Glossary.html#dotted_list"
><EM CLASS="term"
>dotted list</EM
></A
> or a <A HREF="26_1_Glossary.html#circular_list"
><EM CLASS="term"
>circular list</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>tail</VAR
> &#8212; an <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
><A HREF="f_rest.html" CLASS="funref"
><B
>rest</B
></A
> performs the same operation as <A HREF="f_car.html" CLASS="funref"
><B
>cdr</B
></A
>, but mnemonically complements <A HREF="f_first.html" CLASS="funref"
><B
>first</B
></A
>. Specifically,</P
><PRE CLASS="screen"
>(rest <VAR CLASS="param"
>list</VAR
>) <SPAN CLASS="cmsy"
><SPAN STYLE="font-size:16px;vertical-align:-2px"
>&#8801;</SPAN
></SPAN
> (cdr <VAR CLASS="param"
>list</VAR
>)
(setf (rest <VAR CLASS="param"
>list</VAR
>) <VAR CLASS="param"
>new-tail</VAR
>) <SPAN CLASS="cmsy"
><SPAN STYLE="font-size:16px;vertical-align:-2px"
>&#8801;</SPAN
></SPAN
> (setf (cdr <VAR CLASS="param"
>list</VAR
>) <VAR CLASS="param"
>new-tail</VAR
>)</PRE
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
>(rest '(1 2)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> (2)
(rest '(1 . 2)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> 2
(rest '(1)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> NIL
(setq *cons* '(1 . 2)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> (1 . 2)
(setf (rest *cons*) "two") <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> "two"
*cons* <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> (1 . "two")</PRE
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_car.html" CLASS="funref"
><B
>cdr</B
></A
>, <A HREF="f_nthcdr.html" CLASS="funref"
><B
>nthcdr</B
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><P CLASS="j"
><A HREF="f_rest.html" CLASS="funref"
><B
>rest</B
></A
> is often preferred stylistically over <A HREF="f_car.html" CLASS="funref"
><B
>cdr</B
></A
> when the argument is to being subjectively viewed as a <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
> rather than as a <A HREF="26_1_Glossary.html#cons"
><EM CLASS="term"
>cons</EM
></A
>.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_nthcdr.html" CLASS="prev"
>&#8592;</A
><A HREF="f_member.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
>