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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
|
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
Generated from r6rs-lib.tex by tex2page, v 20070803
(running on MzScheme 371, unix),
(c) Dorai Sitaram,
http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
-->
<head>
<title>
r6rs-lib
</title>
<link rel="stylesheet" type="text/css" href="r6rs-lib-Z-S.css" title=default>
<meta name=robots content="index,follow">
</head>
<body>
<div id=slidecontent>
<div align=right class=navigation>[Go to <span><a href="r6rs-lib.html">first</a>, <a href="r6rs-lib-Z-H-3.html">previous</a></span><span>, <a href="r6rs-lib-Z-H-5.html">next</a></span> page<span>; </span><span><a href="r6rs-lib-Z-H-1.html#node_toc_start">contents</a></span><span><span>; </span><a href="r6rs-lib-Z-H-21.html#node_index_start">index</a></span>]</div>
<p></p>
<a name="node_chap_3"></a>
<h1 class=chapter>
<div class=chapterheading><a href="r6rs-lib-Z-H-1.html#node_toc_node_chap_3">Chapter 3</a></div><br>
<a href="r6rs-lib-Z-H-1.html#node_toc_node_chap_3">List utilities</a></h1>
<p></p>
<p>
This chapter describes the <tt>(rnrs lists (6))</tt><a name="node_idx_200"></a>library, which
contains various useful procedures that operate on lists.</p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_202"></a>find<i> proc list</i>)</tt> procedure </div>
<p>
<i>Proc</i> should accept one argument
and return a single value. <i>Proc</i> should not mutate <i>list</i>.
The <tt>find</tt> procedure applies <i>proc</i> to the elements of
<i>list</i> in order. If <i>proc</i> returns a true value for an
element, <tt>find</tt> immediately returns that element. If <i>proc</i>
returns <tt>#f</tt> for all elements of the list, <tt>find</tt> returns
<tt>#f</tt>. <i>Proc</i> is always called in the same dynamic environment
as <tt>find</tt> itself.</p>
<p>
</p>
<tt>(find even? ’(3 1 4 1 5 9)) ⇒ 4<br>
(find even? ’(3 1 5 1 5 9)) ⇒ <tt>#f</tt><br>
<p></tt></p>
<p>
<em>Implementation responsibilities: </em>The implementation must check that <i>list</i> is a chain of
pairs up to the found element, or that it is indeed a list if no
element is found. It should not check that it is a chain of pairs
beyond the found element. The implementation must check the restrictions on
<i>proc</i> to the extent performed by applying it as described.
An
implementation may check whether <i>proc</i> is an appropriate argument
before applying it.
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_204"></a>for-all<i> proc <i>list<sub>1</sub></i> <i>list<sub>2</sub></i> <tt>...</tt> <i>list<sub><em>n</em></sub></i></i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_206"></a>exists<i> proc <i>list<sub>1</sub></i> <i>list<sub>2</sub></i> <tt>...</tt> <i>list<sub><em>n</em></sub></i></i>)</tt> procedure </div>
<p>
The <i>list</i>s should all have the same length, and
<i>proc</i> should accept <em>n</em> arguments and
return a single value.
<i>Proc</i> should not mutate the <i>list</i> arguments.</p>
<p>
For natural numbers <em>i</em> = 0, 1, <tt>...</tt>, the <tt>for-all</tt> procedure
successively applies <i>proc</i> to arguments <em>x</em><sub><em>i</em></sub><sup>1</sup> <tt>...</tt> <em>x</em><sub><em>i</em></sub><sup><em>n</em></sup>,
where <em>x</em><sub><em>i</em></sub><sup><em>j</em></sup> is the <em>i</em>th element of <i>list<sub><em>j</em></sub></i>, until <tt>#f</tt> is
returned. If <i>proc</i> returns true values for all but the last
element of <i>list<sub>1</sub></i>, <tt>for-all</tt> performs a tail call of <i>proc</i>
on the <em>k</em>th elements, where <em>k</em> is the length of <i>list<sub>1</sub></i>. If <i>proc</i>
returns <tt>#f</tt> on any set of elements, <tt>for-all</tt> returns
<tt>#f</tt> after the first such application of <i>proc</i>.
If the <i>list</i>s are all empty, <tt>for-all</tt> returns <tt>#t</tt>.</p>
<p>
For natural numbers <em>i</em> = 0, 1, <tt>...</tt>, the <tt>exists</tt> procedure
applies <i>proc</i> successively to arguments <em>x</em><sub><em>i</em></sub><sup>1</sup> <tt>...</tt> <em>x</em><sub><em>i</em></sub><sup><em>n</em></sup>,
where <em>x</em><sub><em>i</em></sub><sup><em>j</em></sup> is the <em>i</em>th element of <i>list<sub><em>j</em></sub></i>, until a true value is
returned. If <i>proc</i> returns <tt>#f</tt> for all but the last
elements of the <i>list</i>s, <tt>exists</tt> performs a tail call of
<i>proc</i> on the <em>k</em>th elements, where <em>k</em> is the length of
<i>list<sub>1</sub></i>.
If <i>proc</i> returns a true value on any set of elements, <tt>exists</tt> returns that value after the first such application of
<i>proc</i>. If the <i>list</i>s
are all empty, <tt>exists</tt> returns <tt>#f</tt>.</p>
<p>
<i>Proc</i> is always called in the same dynamic environment
as <tt>for-all</tt> or, respectively, <tt>exists</tt> itself.</p>
<p>
</p>
<tt>(for-all even? ’(3 1 4 1 5 9)) <br> ⇒ <tt>#f</tt><br>
(for-all even? ’(3 1 4 1 5 9 . 2)) <br> ⇒ <tt>#f</tt><br>
(for-all even? ’(2 4 14)) ⇒ <tt>#t</tt><br>
(for-all even? ’(2 4 14 . 9)) <br> ⇒ <tt> <tt>&assertion</tt></tt> <i>exception</i><br>
(for-all (lambda (n) (and (even? n) n))<br>
’(2 4 14)) <br> ⇒ 14<br>
(for-all < ’(1 2 3) ’(2 3 4)) <br> ⇒ <tt>#t</tt><br>
(for-all < ’(1 2 4) ’(2 3 4)) <br> ⇒ <tt>#f</tt><br>
<br>
(exists even? ’(3 1 4 1 5 9)) <br> ⇒ <tt>#t</tt><br>
(exists even? ’(3 1 1 5 9)) ⇒ <tt>#f</tt><br>
(exists even? ’(3 1 1 5 9 . 2)) <br> ⇒ <tt> <tt>&assertion</tt></tt> <i>exception</i><br>
(exists (lambda (n) (and (even? n) n)) ’(2 1 4 14)) <br> ⇒ 2<br>
(exists < ’(1 2 4) ’(2 3 4)) ⇒ <tt>#t</tt><br>
(exists > ’(1 2 3) ’(2 3 4)) ⇒ <tt>#f</tt><br>
<p></tt></p>
<p>
<em>Implementation responsibilities: </em>The implementation must check that the <i>list</i>s are
chains of pairs to the extent necessary to determine the return value.
If this requires traversing the lists entirely, the implementation
should check that the <i>list</i>s all have the same length. If not,
it should not check that the <i>list</i>s are chains of pairs beyond
the traversal. The implementation must check the restrictions on
<i>proc</i> to the extent performed by applying it as described.
An
implementation may check whether <i>proc</i> is an appropriate argument
before applying it.
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_208"></a>filter<i> proc list</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_210"></a>partition<i> proc list</i>)</tt> procedure </div>
<p>
<i>Proc</i> should accept one argument
and return a single value. <i>Proc</i> should not mutate <i>list</i>.</p>
<p>
The <tt>filter</tt> procedure applies
<i>proc</i> to each element of <i>list</i> and returns a list of
the elements of <i>list</i> for which <i>proc</i> returned a true
value. The <tt>partition</tt> procedure also applies <i>proc</i> to
each element of <i>list</i>, but returns two values, the first one a
list of the elements of <i>list</i> for which <i>proc</i> returned a
true value, and the second a list of the elements of <i>list</i> for
which <i>proc</i> returned <tt>#f</tt>.
In both cases, the elements of the result list(s) are in the same
order as they appear in the input list.
<i>Proc</i> is always called in the same dynamic environment
as <tt>filter</tt> or, respectively, <tt>partition</tt> itself.
If multiple returns occur from <tt>filter</tt> or <tt>partitions</tt>, the return
values returned by earlier returns are not mutated.</p>
<p>
</p>
<tt>(filter even? ’(3 1 4 1 5 9 2 6)) <br> ⇒ (4 2 6)<br>
<br>
(partition even? ’(3 1 4 1 5 9 2 6)) <br> ⇒ (4 2 6) (3 1 1 5 9) ; two values<br>
<p></tt></p>
<p>
<em>Implementation responsibilities: </em>The implementation must check the restrictions on <i>proc</i>
to the extent performed by applying it as described.
An
implementation may check whether <i>proc</i> is an appropriate argument
before applying it.
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_212"></a>fold-left<i> combine nil <i>list<sub>1</sub></i> <i>list<sub>2</sub></i> <tt>...</tt><i>list<sub><em>n</em></sub></i></i>)</tt> procedure </div>
<p>
The <i>list</i>s should all have the same
length. <i>Combine</i> must be a procedure. It should accept one more
argument than there are <i>list</i>s and return a single value.
It should not mutate the <i>list</i> arguments.
The <tt>fold-left</tt> procedure iterates the <i>combine</i> procedure over an
accumulator value and the elements of the <i>list</i>s from left to
right, starting with an accumulator value of <i>nil</i>. More
specifically, <tt>fold-left</tt> returns <i>nil</i> if the <i>list</i>s are
empty. If they are not empty, <i>combine</i> is first applied to
<i>nil</i> and the respective first elements of the <i>list</i>s in
order. The result becomes the new accumulator value, and <i>combine</i>
is applied to the new accumulator value and the respective next elements
of the <i>list</i>. This step is repeated until the end of the list is
reached; then the accumulator value is returned.
<i>Combine</i> is always called in the same dynamic environment
as <tt>fold-left</tt> itself.</p>
<p>
</p>
<tt>(fold-left + 0 ’(1 2 3 4 5)) ⇒ 15<br>
<br>
(fold-left (lambda (a e) (cons e a)) ’()<br>
’(1 2 3 4 5)) <br> ⇒ (5 4 3 2 1)<br>
<br>
(fold-left (lambda (count x)<br>
(if (odd? x) (+ count 1) count))<br>
0<br>
’(3 1 4 1 5 9 2 6 5 3)) <br> ⇒ 7<br>
<br>
(fold-left (lambda (max-len s)<br>
(max max-len (string-length s)))<br>
0<br>
’("longest" "long" "longer")) <br> ⇒ 7<br>
<br>
(fold-left cons ’(q) ’(a b c)) <br> ⇒ ((((q) . a) . b) . c)<br>
<br>
(fold-left + 0 ’(1 2 3) ’(4 5 6)) <br> ⇒ 21<br>
<p></tt></p>
<p>
<em>Implementation responsibilities: </em>The implementation should check that the <i>list</i>s all
have the same length. The implementation must check the restrictions
on <i>combine</i> to the extent performed by applying it as described.
An
implementation may check whether <i>combine</i> is an appropriate argument
before applying it.
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_214"></a>fold-right<i> combine nil <i>list<sub>1</sub></i> <i>list<sub>2</sub></i> <tt>...</tt><i>list<sub><em>n</em></sub></i></i>)</tt> procedure </div>
<p>
The <i>list</i>s should all have the same
length. <i>Combine</i> must be a procedure. It should accept one more
argument than there are <i>list</i>s and return a single value.
<i>Combine</i> should not mutate the <i>list</i> arguments.
The <tt>fold-right</tt> procedure iterates the <i>combine</i> procedure over
the elements of the <i>list</i>s from right to left and an accumulator
value, starting with an accumulator value of <i>nil</i>. More
specifically, <tt>fold-right</tt> returns <i>nil</i> if the <i>list</i>s
are empty. If they are not empty, <i>combine</i> is first applied to the
respective last elements of the <i>list</i>s in order and <i>nil</i>.
The result becomes the new accumulator value, and <i>combine</i> is
applied to the respective previous elements of the <i>list</i>s and the
new accumulator value. This step is repeated until the beginning of the
list is reached; then the accumulator value is returned.
<i>Proc</i> is always called in the same dynamic environment
as <tt>fold-right</tt> itself.</p>
<p>
</p>
<tt>(fold-right + 0 ’(1 2 3 4 5)) <br> ⇒ 15<br>
<br>
(fold-right cons ’() ’(1 2 3 4 5)) <br> ⇒ (1 2 3 4 5)<br>
<br>
(fold-right (lambda (x l)<br>
(if (odd? x) (cons x l) l))<br>
’()<br>
’(3 1 4 1 5 9 2 6 5))<br>
⇒ (3 1 1 5 9 5)<br>
<br>
(fold-right cons ’(q) ’(a b c)) <br> ⇒ (a b c q)<br>
<br>
(fold-right + 0 ’(1 2 3) ’(4 5 6)) <br> ⇒ 21<br>
<p></tt></p>
<p>
<em>Implementation responsibilities: </em>The implementation should check that the <i>list</i>s all
have the same length. The implementation must check the restrictions
on <i>combine</i> to the extent performed by applying it as described.
An
implementation may check whether <i>combine</i> is an appropriate argument
before applying it.
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_216"></a>remp<i> proc list</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_218"></a>remove<i> obj list</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_220"></a>remv<i> obj list</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_222"></a>remq<i> obj list</i>)</tt> procedure </div>
<p>
<i>Proc</i> should accept one argument
and return a single value.
<i>Proc</i> should not mutate <i>list</i>.</p>
<p>
Each of these procedures returns a list of the elements of <i>list</i>
that do not satisfy a given condition. The <tt>remp</tt> procedure
applies <i>proc</i> to each element of <i>list</i> and returns a
list of the elements of <i>list</i> for which <i>proc</i> returned
<tt>#f</tt>. <i>Proc</i> is always called in the same dynamic environment
as <tt>remp</tt> itself.
The <tt>remove</tt>, <tt>remv</tt>, and <tt>remq</tt> procedures return a list of
the elements that are not <i>obj</i>. The <tt>remq</tt> procedure uses <tt>eq?</tt> to
compare <i>obj</i> with the elements of <i>list</i>, while <tt>remv</tt>
uses <tt>eqv?</tt> and <tt>remove</tt> uses <tt>equal?</tt>.
The elements of the result list are in the same
order as they appear in the input list.
If multiple returns occur from <tt>remp</tt>, the return
values returned by earlier returns are not mutated.</p>
<p>
</p>
<tt>(remp even? ’(3 1 4 1 5 9 2 6 5)) <br> ⇒ (3 1 1 5 9 5)<br>
<br>
(remove 1 ’(3 1 4 1 5 9 2 6 5)) <br> ⇒ (3 4 5 9 2 6 5)<br>
<br>
(remv 1 ’(3 1 4 1 5 9 2 6 5)) <br> ⇒ (3 4 5 9 2 6 5)<br>
<br>
(remq ’foo ’(bar foo baz)) ⇒ (bar baz)<br>
<p></tt></p>
<p>
<em>Implementation responsibilities: </em>The implementation must check the restrictions on <i>proc</i>
to the extent performed by applying it as described.
An
implementation may check whether <i>proc</i> is an appropriate argument
before applying it.
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_224"></a>memp<i> proc list</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_226"></a>member<i> obj list</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_228"></a>memv<i> obj list</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_230"></a>memq<i> obj list</i>)</tt> procedure </div>
<p>
<i>Proc</i> should accept one argument
and return a single value. <i>Proc</i> should not mutate <i>list</i>.</p>
<p>
These procedures return the first sublist of <i>list</i> whose car
satisfies a given condition, where the sublists of <i>lists</i> are the
lists returned by <tt>(list-tail <i>list</i> <i>k</i>)</tt> for
<i>k</i> less than the length of <i>list</i>. The <tt>memp</tt> procedure applies
<i>proc</i> to the cars of the sublists of <i>list</i> until it
finds one for which <i>proc</i> returns a true value.
<i>Proc</i> is always called in the same dynamic environment
as <tt>memp</tt> itself. The <tt>member</tt>, <tt>memv</tt>, and <tt>memq</tt> procedures look for the first occurrence of
<i>obj</i>. If <i>list</i> does not contain an element satisfying the
condition, then <tt>#f</tt> (not the empty list) is returned. The <tt>member</tt> procedure uses <tt>equal?</tt> to compare <i>obj</i> with the elements of
<i>list</i>, while <tt>memv</tt> uses <tt>eqv?</tt> and <tt>memq</tt> uses
<tt>eq?</tt>.</p>
<p>
</p>
<tt>(memp even? ’(3 1 4 1 5 9 2 6 5)) <br> ⇒ (4 1 5 9 2 6 5)<br>
<br>
(memq ’a ’(a b c)) ⇒ (a b c)<br>
(memq ’b ’(a b c)) ⇒ (b c)<br>
(memq ’a ’(b c d)) ⇒ <tt>#f</tt><br>
(memq (list ’a) ’(b (a) c)) ⇒ <tt>#f</tt><br>
(member (list ’a)<br>
’(b (a) c)) ⇒ ((a) c)<br>
(memq 101 ’(100 101 102)) ⇒ <i>unspecified</i><br>
(memv 101 ’(100 101 102)) ⇒ (101 102)<p></tt> </p>
<p>
<em>Implementation responsibilities: </em>The implementation must check that <i>list</i> is a chain of
pairs up to the found element, or that it is indeed a list if no
element is found. It should not check that it is a chain of pairs
beyond the found element. The implementation must check the restrictions on
<i>proc</i> to the extent performed by applying it as described.
An
implementation may check whether <i>proc</i> is an appropriate argument
before applying it.
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_232"></a>assp<i> proc alist</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_234"></a>assoc<i> obj alist</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_236"></a>assv<i> obj alist</i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_238"></a>assq<i> obj alist</i>)</tt> procedure </div>
<p>
<i>Alist</i> (for “association list”) should be a list of pairs.
<i>Proc</i> should accept one argument
and return a single value. <i>Proc</i> should not mutate <i>alist</i>.</p>
<p>
These procedures find the first pair in <i>alist</i>
whose car field satisfies a given condition, and returns that pair
without traversing <i>alist</i> further.
If no pair in <i>alist</i> satisfies the condition, then <tt>#f</tt>
is returned. The <tt>assp</tt> procedure successively applies
<i>proc</i> to the car fields of <i>alist</i> and looks for a pair
for which it returns a true value.
<i>Proc</i> is always called in the same dynamic environment
as <tt>assp</tt> itself. The <tt>assoc</tt>, <tt>assv</tt>, and <tt>assq</tt> procedures look for a pair that has <i>obj</i> as its car. The
<tt>assoc</tt> procedure uses
<tt>equal?</tt> to compare <i>obj</i> with the car fields of the pairs in
<i>alist</i>, while <tt>assv</tt> uses <tt>eqv?</tt> and <tt>assq</tt> uses
<tt>eq?</tt>.</p>
<p>
<em>Implementation responsibilities: </em>The implementation must check that <i>alist</i> is a chain of
pairs containing pairs up to the found pair, or that it is indeed a
list of pairs if no element is found. It should not check that it is
a chain of pairs beyond the found element. The implementation must
check the restrictions on <i>proc</i> to the extent performed by
applying it as described.
An
implementation may check whether <i>proc</i> is an appropriate argument
before applying it.</p>
<p>
</p>
<tt>(define d ’((3 a) (1 b) (4 c)))<br>
<br>
(assp even? d) ⇒ (4 c)<br>
(assp odd? d) ⇒ (3 a)<br>
<br>
(define e ’((a 1) (b 2) (c 3)))<br>
(assq ’a e) ⇒ (a 1)<br>
(assq ’b e) ⇒ (b 2)<br>
(assq ’d e) ⇒ <tt>#f</tt><br>
(assq (list ’a) ’(((a)) ((b)) ((c))))<br>
⇒ <tt>#f</tt><br>
(assoc (list ’a) ’(((a)) ((b)) ((c)))) <br>
⇒ ((a))<br>
(assq 5 ’((2 3) (5 7) (11 13))) <br>
⇒ <i>unspecified</i><br>
(assv 5 ’((2 3) (5 7) (11 13))) <br>
⇒ (5 7)<p></tt></p>
<p>
</p>
<p></p>
<p>
</p>
<p></p>
<div align=left><tt>(<a name="node_idx_240"></a>cons*<i> <i>obj<sub>1</sub></i> <tt>...</tt> <i>obj<sub><em>n</em></sub></i> <i>obj</i></i>)</tt> procedure </div>
<div align=left><tt>(<a name="node_idx_242"></a>cons*<i> <i>obj</i></i>)</tt> procedure </div>
<p>
If called with at least two arguments, <tt>cons*</tt> returns a freshly
allocated chain of pairs whose cars are <i>obj<sub>1</sub></i>, <tt>...</tt>,
<i>obj<sub><em>n</em></sub></i>, and whose last cdr is <i>obj</i>. If called with only one
argument, <tt>cons*</tt> returns that argument.</p>
<p>
</p>
<tt>(cons* 1 2 ’(3 4 5)) ⇒ (1 2 3 4 5)<br>
(cons* 1 2 3) ⇒ (1 2 . 3)<br>
(cons* 1) ⇒ 1<p></tt></p>
<p>
</p>
<p></p>
<p>
</p>
<p>
</p>
<p></p>
<div class=smallskip></div>
<p style="margin-top: 0pt; margin-bottom: 0pt">
<div align=right class=navigation>[Go to <span><a href="r6rs-lib.html">first</a>, <a href="r6rs-lib-Z-H-3.html">previous</a></span><span>, <a href="r6rs-lib-Z-H-5.html">next</a></span> page<span>; </span><span><a href="r6rs-lib-Z-H-1.html#node_toc_start">contents</a></span><span><span>; </span><a href="r6rs-lib-Z-H-21.html#node_index_start">index</a></span>]</div>
</p>
<p></p>
</div>
</body>
</html>
|