Debian Codegraph @

info/gcl/first.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>first (ANSI and GNU Common Lisp Document)</title>
7
8 <meta name="description" content="first (ANSI and GNU Common Lisp Document)">
9 <meta name="keywords" content="first (ANSI and GNU Common Lisp Document)">
10 <meta name="resource-type" content="document">
11 <meta name="distribution" content="global">
12 <meta name="Generator" content="makeinfo">
13 <link href="index.html" rel="start" title="Top">
14 <link href="Conses-Dictionary.html" rel="up" title="Conses Dictionary">
15 <link href="nth.html" rel="next" title="nth">
16 <link href="pop.html" rel="prev" title="pop">
17 <style type="text/css">
18 <!--
19 a.summary-letter {text-decoration: none}
20 blockquote.indentedblock {margin-right: 0em}
21 div.display {margin-left: 3.2em}
22 div.example {margin-left: 3.2em}
23 div.lisp {margin-left: 3.2em}
24 kbd {font-style: oblique}
25 pre.display {font-family: inherit}
26 pre.format {font-family: inherit}
27 pre.menu-comment {font-family: serif}
28 pre.menu-preformatted {font-family: serif}
29 span.nolinebreak {white-space: nowrap}
30 span.roman {font-family: initial; font-weight: normal}
31 span.sansserif {font-family: sans-serif; font-weight: normal}
32 ul.no-bullet {list-style: none}
33 -->
34 </style>
35
36
37 </head>
38
39 <body lang="en">
40 <span id="first"></span><div class="header">
41 <p>
42 Next: <a href="nth.html" accesskey="n" rel="next">nth</a>, Previous: <a href="pop.html" accesskey="p" rel="prev">pop</a>, Up: <a href="Conses-Dictionary.html" accesskey="u" rel="up">Conses Dictionary</a> &nbsp; </p>
43 </div>
44 <hr>
45 <span id="first_002c-second_002c-third_002c-fourth_002c-fifth_002c"></span><h4 class="subsection">14.2.21 first, second, third, fourth, fifth,</h4>
46 <span id="sixth_002c-seventh_002c-eighth_002c-ninth_002c-tenth"></span><h4 class="subheading">sixth, seventh, eighth, ninth, tenth</h4>
47 <p align="right"><i>[Accessor]</i>
48 </p>
49 <p><code>first</code> <i>list</i> &rArr; <i>object</i>
50 (setf (<code>first</code> <i>list</i>) new-object)<br>
51 </p>
52 <p><code>second</code> <i>list</i> &rArr; <i>object</i>
53 (setf (<code>second</code> <i>list</i>) new-object)<br>
54 </p>
55 <p><code>third</code> <i>list</i> &rArr; <i>object</i>
56 (setf (<code>third</code> <i>list</i>) new-object)<br>
57 </p>
58 <p><code>fourth</code> <i>list</i> &rArr; <i>object</i>
59 (setf (<code>fourth</code> <i>list</i>) new-object)<br>
60 </p>
61 <p><code>fifth</code> <i>list</i> &rArr; <i>object</i>
62 (setf (<code>fifth</code> <i>list</i>) new-object)<br>
63 </p>
64 <p><code>sixth</code> <i>list</i> &rArr; <i>object</i>
65 (setf (<code>sixth</code> <i>list</i>) new-object)<br>
66 </p>
67 <p><code>seventh</code> <i>list</i> &rArr; <i>object</i>
68 (setf (<code>seventh</code> <i>list</i>) new-object)<br>
69 </p>
70 <p><code>eighth</code> <i>list</i> &rArr; <i>object</i>
71 (setf (<code>eighth</code> <i>list</i>) new-object)<br>
72 </p>
73 <p><code>ninth</code> <i>list</i> &rArr; <i>object</i>
74 (setf (<code>ninth</code> <i>list</i>) new-object)<br>
75 </p>
76 <p><code>tenth</code> <i>list</i> &rArr; <i>object</i>
77 (setf (<code>tenth</code> <i>list</i>) new-object)<br>
78 </p>
79 <span id="Arguments-and-Values_003a_003a-290"></span><h4 class="subsubheading">Arguments and Values::</h4>
80
81 <p><i>list</i>&mdash;a <i>list</i>,
82 </p>
83 <p>which might be a <i>dotted list</i> or a <i>circular list</i>.
84 </p>
85 <p><i>object</i>, <i>new-object</i>&mdash;an <i>object</i>.
86 </p>
87 <span id="Description_003a_003a-391"></span><h4 class="subsubheading">Description::</h4>
88
89 <p>The functions
90 <b>first</b>,
91 <b>second</b>,
92 <b>third</b>,
93 <b>fourth</b>,
94 <b>fifth</b>,
95 <b>sixth</b>,
96 <b>seventh</b>,
97 <b>eighth</b>,
98 <b>ninth</b>,
99 and
100 <b>tenth</b>
101 <i>access</i> the first, second, third, fourth, fifth, sixth, seventh, eighth,
102 ninth, and tenth <i>elements</i> of <i>list</i>, respectively.
103 Specifically,
104 </p>
105 <div class="example">
106 <pre class="example"> (first <i>list</i>) &equiv; (car <i>list</i>)
107 (second <i>list</i>) &equiv; (car (cdr <i>list</i>))
108 (third <i>list</i>) &equiv; (car (cddr <i>list</i>))
109 (fourth <i>list</i>) &equiv; (car (cdddr <i>list</i>))
110 (fifth <i>list</i>) &equiv; (car (cddddr <i>list</i>))
111 (sixth <i>list</i>) &equiv; (car (cdr (cddddr <i>list</i>)))
112 (seventh <i>list</i>) &equiv; (car (cddr (cddddr <i>list</i>)))
113 (eighth <i>list</i>) &equiv; (car (cdddr (cddddr <i>list</i>)))
114 (ninth <i>list</i>) &equiv; (car (cddddr (cddddr <i>list</i>)))
115 (tenth <i>list</i>) &equiv; (car (cdr (cddddr (cddddr <i>list</i>))))
116 </pre></div>
117
118 <p><b>setf</b> can also be used with any of these functions to change an
119 existing component. The same equivalences apply. For example:
120 </p>
121 <div class="example">
122 <pre class="example"> (setf (fifth <i>list</i>) <i>new-object</i>) &equiv; (setf (car (cddddr <i>list</i>)) <i>new-object</i>)
123 </pre></div>
124
125 <span id="Examples_003a_003a-274"></span><h4 class="subsubheading">Examples::</h4>
126
127 <div class="example">
128 <pre class="example"> (setq lst '(1 2 3 (4 5 6) ((V)) vi 7 8 9 10))
129 &rArr; (1 2 3 (4 5 6) ((V)) VI 7 8 9 10)
130 (first lst) &rArr; 1
131 (tenth lst) &rArr; 10
132 (fifth lst) &rArr; ((V))
133 (second (fourth lst)) &rArr; 5
134 (sixth '(1 2 3)) &rArr; NIL
135 (setf (fourth lst) &quot;four&quot;) &rArr; &quot;four&quot;
136 lst &rArr; (1 2 3 &quot;four&quot; ((V)) VI 7 8 9 10)
137 </pre></div>
138
139 <span id="See-Also_003a_003a-317"></span><h4 class="subsubheading">See Also::</h4>
140
141 <p><a href="car.html">car</a>
142 ,
143 <a href="nth.html">nth</a>
144 </p>
145 <span id="Notes_003a_003a-210"></span><h4 class="subsubheading">Notes::</h4>
146
147 <p><b>first</b> is functionally equivalent to <b>car</b>,
148 <b>second</b> is functionally equivalent to <b>cadr</b>,
149 <b>third</b> is functionally equivalent to <b>caddr</b>, and
150 <b>fourth</b> is functionally equivalent to <b>cadddr</b>.
151 </p>
152 <p>The ordinal numbering used here is one-origin,
153 as opposed to the zero-origin numbering used by <b>nth</b>:
154 </p>
155 <div class="example">
156 <pre class="example"> (fifth x) &equiv; (nth 4 x)
157 </pre></div>
158
159 <hr>
160 <div class="header">
161 <p>
162 Next: <a href="nth.html" accesskey="n" rel="next">nth</a>, Previous: <a href="pop.html" accesskey="p" rel="prev">pop</a>, Up: <a href="Conses-Dictionary.html" accesskey="u" rel="up">Conses Dictionary</a> &nbsp; </p>
163 </div>
164
165
166
167 </body>
168 </html>