[LISPWORKS][Common Lisp HyperSpec (TM)] [Previous][Up][Next]


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.

Description:

Returns the tail of list that would be obtained by calling cdr n times in succession.

Examples:

 (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:

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.


The following X3J13 cleanup issues, not part of the specification, apply to this section:


[Starting Points][Contents][Index][Symbols][Glossary][Issues]
Copyright 1996-2005, LispWorks Ltd. All rights reserved.