User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:rest [2019/09/14 05:00]
cl:functions:rest [2019/09/20 16:00] (current)
Line 1: Line 1:
 +====== Accessor REST ======
  
 +====Syntax====
 +  * **rest** //list// → //tail//
 +  * (**setf** (**rest** //list//) //​new-tail//​)
 +
 +====Arguments and Values====
 +  * //list// - a //​[[CL:​Glossary:​list]]//,​ which might be a //​[[CL:​Glossary:​dotted list]]// or a //​[[CL:​Glossary:​circular list]]//.
 +  * //tail// - an //​[[CL:​Glossary:​object]]//​.
 +
 +====Description====
 +**rest** performs the same operation as **[[CL:​Functions:​cdr]]**,​ but mnemonically complements **[[CL:​Functions:​first]]**. Specifically,​
 +
 +<​blockquote>​
 + (rest list) ≡ ([[CL:​Functions:​cdr]] list)
 + ​([[CL:​Macros:​setf]] (rest list) new-tail) ≡ ([[CL:​Macros:​setf]] ([[CL:​Functions:​cdr]] list) new-tail)
 +</​blockquote>​
 +
 +====Examples====
 +<​blockquote>​
 +(rest '(1 2)) <​r>​(2)</​r>​
 +(rest '(1 . 2)) <​r>​2</​r>​
 +(rest '(1)) <​r>​[[CL:​Constant Variable:​nil|NIL]]</​r>​
 +([[CL:​Macros:​defparameter]] *cons* '(1 . 2)) <​r>​*CONS*</​r>​
 +([[CL:​Macros:​setf]] (rest *cons*) "​two"​) <​r>"​two"</​r>​
 +*cons* <r>(1 . "​two"​)</​r>​
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +**[[CL:​Functions:​cdr|Function CDR]]**, **[[CL:​Functions:​nthcdr|Function NTHCDR]]**
 +
 +====Example Implementation====
 +**rest** is often preferred stylistically over **[[CL:​Functions:​cdr]]** when the argument is to being subjectively viewed as a //​[[CL:​Glossary:​list]]// ​ rather than as a //​[[CL:​Glossary:​cons]]//​.
 +
 +====Notes====
 +None.
 +
 +\issue{DOTTED-LIST-ARGUMENTS:​CLARIFY}