User Tools


Accessor FIRST, ..., TENTH

Syntax

  • first listobject
  • second listobject
  • third listobject
  • fourth listobject
  • fifth listobject
  • sixth listobject
  • seventh listobject
  • eighth listobject
  • ninth listobject
  • tenth listobject
  • (setf (first object) new-object)
  • (setf (second object) new-object)
  • (setf (third object) new-object)
  • (setf (fourth object) new-object)
  • (setf (fifth object) new-object)
  • (setf (sixth object) new-object)
  • (setf (seventh object) new-object)
  • (setf (eighth object) new-object)
  • (setf (ninth object) new-object)
  • (setf (tenth object) new-object)

Arguments and Values

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

(defparameter *list* '(1 2 3 (4 5 6) ((V)) vi 7 8 9 10))

*LIST*

*list*

(1 2 3 (4 5 6) ((V)) VI 7 8 9 10)

(first *list*)

1

(tenth *list*)

10

(fifth *list*)

((V))

(second (fourth *list*))

5

(sixth '(1 2 3))

NIL

(setf (fourth *list*) "four")

"four"

*list*

(1 2 3 "four" ((V)) VI 7 8 9 10)

Side Effects

None.

Affected By

None.

Exceptional Situations

None.

See Also

Example Implementation

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.

Notes

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

(fifth x) ≡ (nth 4 x)

\issue{DOTTED-LIST-ARGUMENTS:CLARIFY}