User Tools

A PCRE internal error occured. This might be caused by a faulty plugin

====== Accessor FIRST, ..., TENTH ====== ====Syntax==== * **first** //list// → //object// * **second** //list// → //object// * **third** //list// → //object// * **fourth** //list// → //object// * **fifth** //list// → //object// * **sixth** //list// → //object// * **seventh** //list// → //object// * **eighth** //list// → //object// * **ninth** //list// → //object// * **tenth** //list// → //object// * (**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==== * //list// - a //[[CL:Glossary:list]]//, which might be a //[[CL:Glossary:dotted list]]// or a //[[CL:Glossary: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 //[[CL:Glossary:element|elements]]// of //list//, respectively. Specifically, <blockquote> (first //list//) ≡ ([[CL:Function:car]] //list//) (second //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cdr]] //list//)) (third //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cddr]] //list//)) (fourth //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cdddr]] //list//)) (fifth //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cddddr]] //list//)) (sixth //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cdr]] ([[CL:Function:cddddr]] //list//))) (seventh //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cddr]] ([[CL:Function:cddddr]] //list//))) (eighth //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cdddr]] ([[CL:Function:cddddr]] //list//))) (ninth //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cddddr]] ([[CL:Function:cddddr]] //list//))) (tenth //list//) ≡ ([[CL:Function:car]] ([[CL:Function:cdr]] ([[CL:Function:cddddr]] ([[CL:Function:cddddr]] //list//)))) </blockquote> **[[CL:Macros:setf]]** can also be used with any of these functions to change an existing component. The same equivalences apply. For example: <blockquote> ([[CL:Macros:setf]] (fifth list) new-object) ≡ ([[CL:Macros:setf]] ([[CL:Function:car]] ([[CL:Function:cddddr]] list)) new-object) </blockquote> ====Examples==== <blockquote> ([[CL:Macros:defparameter]] *list* '(1 2 3 (4 5 6) ((V)) vi 7 8 9 10)) <r>*LIST*</r> *list* <r>(1 2 3 (4 5 6) ((V)) VI 7 8 9 10)</r> (first *list*) <r>1</r> (tenth *list*) <r>10</r> (fifth *list*) <r>((V))</r> (second (fourth *list*)) <r>5</r> (sixth '(1 2 3)) <r>[[CL:Constant Variable:nil|NIL]]</r> ([[CL:Macros:setf]] (fourth *list*) "four") <r>"four"</r> *list* <r>(1 2 3 "four" ((V)) VI 7 8 9 10)</r> </blockquote> ====Side Effects==== None. ====Affected By==== None. ====Exceptional Situations==== None. ====See Also==== **[[CL:Functions:car|Function CAR]]**, **[[CL:Functions:nth|Function NTH]]** ====Example Implementation==== **first** is functionally equivalent to **[[CL:Functions:car]]**, **second** is functionally equivalent to **[[CL:Functions:cadr]]**, **third** is functionally equivalent to **[[CL:Functions:caddr]]**, and **fourth** is functionally equivalent to **[[CL:Functions:cadddr]]**. ====Notes==== The ordinal numbering used here is one-origin, as opposed to the zero-origin numbering used by **[[CL:Functions:nth]]**: <blockquote> (fifth //x//) ≡ ([[CL:Functions:nth]] 4 //x//) </blockquote> \issue{DOTTED-LIST-ARGUMENTS:CLARIFY}