Go to the first, previous, next, last section, table of contents.


first, second, third, fourth, fifth,

sixth, seventh, eighth, ninth, tenth

[Accessor]

first list => object (setf (first list) new-object)

second list => object (setf (second list) new-object)

third list => object (setf (third list) new-object)

fourth list => object (setf (fourth list) new-object)

fifth list => object (setf (fifth list) new-object)

sixth list => object (setf (sixth list) new-object)

seventh list => object (setf (seventh list) new-object)

eighth list => object (setf (eighth list) new-object)

ninth list => object (setf (ninth list) new-object)

tenth list => object (setf (tenth list) new-object)

Arguments and Values::

list---a list,

which might be a dotted list or a circular list.

object, new-object---an object.

Description::

The functions first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, and tenth access the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, and tenth elements of list, respectively. Specifically,

 (first list)    ==  (car list)
 (second list)   ==  (car (cdr list))
 (third list)    ==  (car (cddr list))
 (fourth list)   ==  (car (cdddr list))
 (fifth list)    ==  (car (cddddr list))
 (sixth list)    ==  (car (cdr (cddddr list)))
 (seventh list)  ==  (car (cddr (cddddr list)))
 (eighth list)   ==  (car (cdddr (cddddr list)))
 (ninth list)    ==  (car (cddddr (cddddr list)))
 (tenth list)    ==  (car (cdr (cddddr (cddddr list))))

setf can also be used with any of these functions to change an existing component. The same equivalences apply. For example:

 (setf (fifth list) new-object) == (setf (car (cddddr list)) new-object)

Examples::

 (setq lst '(1 2 3 (4 5 6) ((V)) vi 7 8 9 10)) 
=>  (1 2 3 (4 5 6) ((V)) VI 7 8 9 10)
 (first lst) =>  1
 (tenth lst) =>  10
 (fifth lst) =>  ((V))
 (second (fourth lst)) =>  5
 (sixth '(1 2 3)) =>  NIL
 (setf (fourth lst) "four") =>  "four"
 lst =>  (1 2 3 "four" ((V)) VI 7 8 9 10)

See Also::

@xref{car; cdr; caar; cadr; cdar; cddr; caaar; caadr; cadar; caddr; cdaar; cdadr; cddar; cdddr; caaaar; caaadr; caadar; caaddr; cadaar; cadadr; caddar; cadddr; cdaaar; cdaadr; cdadar; cdaddr; cddaar; cddadr; cdddar; cddddr} , section nth [Accessor]

Notes::

first is functionally equivalent to car, second is functionally equivalent to cadr, third is functionally equivalent to caddr, and fourth is functionally equivalent to cadddr.

The ordinal numbering used here is one-origin, as opposed to the zero-origin numbering used by nth:

 (fifth x) == (nth 4 x)


Go to the first, previous, next, last section, table of contents.