ToC DocOverview CGDoc RelNotes Index PermutedIndex
Allegro CL ANSI Common Lisp 14 Conses 14.2 Dictionary of Conses

 14.2.21 first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth Accessor

Syntax:
 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)
```

car, nth

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)
```

Allegro CL Implementation Details:
None. © Franz Inc. 1998-2019 - File last updated 02-07-2019
{"ft_lang_label":"__label__en","ft_lang_prob":0.73862094,"math_prob":0.8610724,"size":2312,"snap":"2021-43-2021-49","text_gpt3_token_len":745,"char_repetition_ratio":0.21403813,"word_repetition_ratio":0.07631579,"special_character_ratio":0.33434257,"punctuation_ratio":0.13064133,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98134047,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-04T17:19:30Z\",\"WARC-Record-ID\":\"<urn:uuid:d1665b07-4ba9-4ce4-88fa-2395cfd381c9>\",\"Content-Length\":\"10870\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:aa19541e-3841-4e3c-afa9-238ca1efa04f>\",\"WARC-Concurrent-To\":\"<urn:uuid:1cd618c9-efaa-443a-a907-564407ebc04b>\",\"WARC-IP-Address\":\"192.235.120.131\",\"WARC-Target-URI\":\"https://franz.com/support/documentation/current/ansicl/dictentr/firstsec.htm\",\"WARC-Payload-Digest\":\"sha1:4XLZ4BYXCUFNMFYJYLWBUEKODMYTAG7V\",\"WARC-Block-Digest\":\"sha1:R65673Q3K4SE2POOTQFQSY5IJGWMQMKE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964362999.66_warc_CC-MAIN-20211204154554-20211204184554-00441.warc.gz\"}"}