Function nthcdr

Syntax:

nthcdr n list tail

Arguments and Values:

n—a non-negative integer.

list—a list, which might be a dotted list or a circular list.

tail—an object. \term{tail} of the \param{list}.

Description:

15.2.0 14 Described using more descriptive terminology, in a way that doesn't get confused about whether n is 0-based or 1-based. -kmp 29-Aug-93 Returns the \param{n}th successive \term{cdr} of \param{list}.Returns the tail of list that would be obtained by calling cdr n times in succession.

Examples:

I added an example of high-safety error, to demonstrate relation of NTHCDR and CDR. -kmp 26-Aug-93

 (nthcdr 0 '()) → NIL
 (nthcdr 3 '()) → NIL
 (nthcdr 0 '(a b c)) → (A B C)
 (nthcdr 2 '(a b c)) → (C)
 (nthcdr 4 '(a b c)) → ()
 (nthcdr 1 '(0 . 1)) → 1

 (locally (declare (optimize (safety 3)))
   (nthcdr 3 '(0 . 1)))
 Error: Attempted to take CDR of 1.

Side Effects:

None.

Affected By:

None.

Exceptional Situations:

I added this stuff because it seemed consistent with the other entries. -kmp 26-Aug-93

Should signal an error of type type-error if n is not a non-negative 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 function cdr.

See Also:

cdr, nth, rest

Notes:

None.