next up previous
Contents Next: null (PREDICATE) Up: Appendix: Selected Lisp Previous: nth (FUNCTION)

nthcdr (FUNCTION)

Format: (nthcdr <index> <list> )

Required arguments: 2

<index> : any expression which returns a positive integer (fixnum). <list> : any expression which returns a list.

The function nth returns the <list> with the first n elements removed. <index> must be a non-negative integer. An index past the end of the list will cause nthcdr to return nil.

Examples:

> (setf ds9 '(Sisko Kira Dax Odo Bashir OBrien))
(SISKO KIRA DAX ODO BASHIR OBRIEN)

> (nthcdr 0 ds9)
(SISKO KIRA DAX ODO BASHIR OBRIEN)

> (nthcdr 1 ds9)
(KIRA DAX ODO BASHIR OBRIEN)

> (nthcdr 3 ds9)
(ODO BASHIR OBRIEN)

> (nthcdr 2345 ds9)
NIL



© Colin Allen & Maneesh Dhagat
March 2007