User Tools


Differences

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

Link to this comparison view

cl:functions:nthcdr [2019/06/15 02:00]
cl:functions:nthcdr [2019/11/12 05:00] (current)
Line 1: Line 1:
 +====== Function NTHCDR ======
  
 +====Syntax====
 +  * **nthcdr** //n list// → //tail//
 +
 +====Arguments and Values====
 +  * //n// - a non-negative //​[[CL:​Glossary:​integer]]//​.
 +  * //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====
 +Returns the //​[[CL:​Glossary:​tail]]//​ of //list// that would be obtained by calling **[[CL:​Functions:​cdr]]** //n// times in succession.
 +
 +====Examples====
 +<​blockquote>​
 +(nthcdr 0 '()) <​r>​[[CL:​Constant Variable:​nil|NIL]]</​r>​
 +(nthcdr 3 '()) <​r>​[[CL:​Constant Variable:​nil|NIL]]</​r>​
 +(nthcdr 0 '(a b c)) <r>(A B C)</​r>​
 +(nthcdr 2 '(a b c)) <​r>​(C)</​r>​
 +(nthcdr 4 '(a b c)) <​r>​[[CL:​Constant Variable:​nil|NIL]]</​r>​
 +(nthcdr 1 '(0 . 1)) <​r>​1</​r>​
 +
 +([[CL:​Special Operators:​locally]] ([[CL:​Symbols:​declare]] ([[CL:​Declarations:​optimize]] (safety 3)))
 +  (nthcdr 3 '(0 . 1)))
 +<​e>​Error:​ Attempted to take CDR of 1.</​e>​
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +Should signal an error of type type-error if //n// is not a non-negative //​[[CL:​Glossary:​integer]]//​.
 +
 +For //n// being an integer greater than ''​1'',​ the error checking done by ''​(nthcdr //n// //​list//​)''​ is the same as for ''​(nthcdr (- //n// 1) (cdr //​list//​))'';​ see the //​[[CL:​Glossary:​function]]//​ **[[CL:​Functions:​cdr]]**.
 +
 +====See Also====
 +**[[CL:​Functions:​cdr|Function CDR]]**, **[[CL:​Functions:​nth|Function NTH]]**, **[[CL:​Functions:​rest|Function REST]]**
 +
 +====Example Implementation====
 +To be done.
 +
 +====Notes====
 +None.
 +
 +\issue{DOTTED-LIST-ARGUMENTS:​CLARIFY}
 +\issue{ARGUMENTS-UNDERSPECIFIED:​SPECIFY}