87 lines
4.0 KiB
HTML
87 lines
4.0 KiB
HTML
<!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-17.html">previous</a></span><span>, <a href="r6rs-lib-Z-H-19.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_17"></a>
|
|
<h1 class=chapter>
|
|
<div class=chapterheading><a href="r6rs-lib-Z-H-1.html#node_toc_node_chap_17">Chapter 17</a></div><br>
|
|
<a href="r6rs-lib-Z-H-1.html#node_toc_node_chap_17">Mutable pairs</a></h1>
|
|
<p></p>
|
|
<p>
|
|
The procedures provided by the <tt>(rnrs mutable-pairs (6))</tt><a name="node_idx_1272"></a>library
|
|
allow new values to be assigned to the car and cdr fields of
|
|
previously allocated pairs. </p>
|
|
<p>
|
|
</p>
|
|
<p></p>
|
|
<div align=left><tt>(<a name="node_idx_1274"></a>set-car!<i> pair obj</i>)</tt> procedure </div>
|
|
<p>
|
|
Stores <i>obj</i> in the car field of <i>pair</i>.
|
|
The <tt>set-car!</tt> procedure returns unspecified values.</p>
|
|
<p>
|
|
</p>
|
|
|
|
<tt>(define (f) (list ’not-a-constant-list))<br>
|
|
(define (g) ’(constant-list))<br>
|
|
(set-car! (f) 3) ⇒ <em>unspecified</em><br>
|
|
(set-car! (g) 3) ⇒ <i>unspecified</i><br>
|
|
; should raise <tt> &assertion</tt> <i>exception</i><br>
|
|
<p></tt></p>
|
|
<p>
|
|
If an immutable pair is passed to <tt>set-car!</tt>, an exception
|
|
with condition type <tt>&assertion</tt> should be raised.
|
|
</p>
|
|
<p></p>
|
|
<p>
|
|
</p>
|
|
<p></p>
|
|
<div align=left><tt>(<a name="node_idx_1276"></a>set-cdr!<i> pair obj</i>)</tt> procedure </div>
|
|
<p>
|
|
Stores <i>obj</i> in the cdr field of <i>pair</i>.
|
|
The <tt>set-cdr!</tt> procedure returns unspecified values.</p>
|
|
<p>
|
|
If an immutable pair is passed to <tt>set-cdr!</tt>, an exception
|
|
with condition type <tt>&assertion</tt> should be raised.</p>
|
|
<p>
|
|
</p>
|
|
|
|
<tt>(let ((x (list ’a ’b ’c ’a))<br>
|
|
(y (list ’a ’b ’c ’a ’b ’c ’a)))<br>
|
|
(set-cdr! (list-tail x 2) x)<br>
|
|
(set-cdr! (list-tail y 5) y)<br>
|
|
(list<br>
|
|
(equal? x x)<br>
|
|
(equal? x y)<br>
|
|
(equal? (list x y ’a) (list y x ’b)))) <br> ⇒ (<tt>#t</tt> <tt>#t</tt> <tt>#f</tt>)<br>
|
|
<p></tt>
|
|
</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-17.html">previous</a></span><span>, <a href="r6rs-lib-Z-H-19.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>
|