<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Many thanks,<br><br> This explanation and the example from Ref. manual 3.9.8 Immutable Cyclic Data makes everything clearer.<br><br>Example:<BR><table cellspacing="0"><tbody><tr><td><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/let.html#%28form._%28%28lib._racket/private/letstx-scheme..rkt%29._let*%29%29" class="RktStxLink">let*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">ph</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._%7E23%7E25kernel%29._make-placeholder%29%29" class="RktValLink">make-placeholder</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="RktPlain"><span class="hspace"> </span></span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._%7E23%7E25kernel%29._cons%29%29" class="RktValLink">cons</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktSym">ph</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPlain"><span class="hspace"> </span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._%7E23%7E25kernel%29._placeholder-set%21%29%29" class="RktValLink">placeholder-set!</a></span><span class="hspace"> </span><span class="RktSym">ph</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPlain"><span class="hspace"> </span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._%7E23%7E25kernel%29._make-reader-graph%29%29" class="RktValLink">make-reader-graph</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></td></tr><tr><td><span class="RktRes">#0=<span class="stt"> </span>'(1<span class="stt"> </span>. #0#)</span><BR></td></tr></tbody></table><br><br><div>> Subject: Re: [racket] Reading graph structure<br>> From: matthias@ccs.neu.edu<br>> Date: Thu, 18 Aug 2011 10:32:21 -0400<br>> CC: users@racket-lang.org<br>> To: harryspier@hotmail.com<br>> <br>> <br>> On Aug 18, 2011, at 10:21 AM, Harry Spier wrote:<br>> <br>> > I've done that and what displays is:<br>> > #0=(1 . #0#)<br>> > #0='(1 . #0#)<br>> > <br>> > Again I'm not clear why this doesn't try to produce an endlessly recurring (1 . (1 . ( 1 ....... list<br>> <br>> At this point you're entering philosophical grounds: <br>> <br>> is a cyclic list (ignoring how it is constructed) a good representation for the rational, infinite list of all 1s? <br>> <br>> As far as my practical programming issues are concerned, I am perfectly happy with it. <br>> <br>> Here is a snippet from a TicTacToe implementation that uses a cyclic list: <br>> <br>> ;; the class of ttt buttons<br>> (define ttt% <br>> (shared ((turn (cons "U, Man" (cons "I, Bot" turn)))) <br>> ;; The above creates the 'infinite' list ("U, Man" . ("I, Bot" . ("U, Man" . ...)))<br>> ;; The first person on this list is the player whose turn it is. <br>> ;; You could create this list by reading the names off some input string. <br>> (class button% <br>> (field [status BLANK])<br>> ;; -> String <br>> ;; what is its status? <br>> (define/public (is) status)<br>> ;; -> Void (effect: this button is taken by the current player)<br>> (define/public (play)<br>> (define who (car turn))<br>> (when (and (send this is-enabled?) (string=? status BLANK))<br>> (set! status who)<br>> (send this set-label status)<br>> (send this enable #f)<br>> (when (N-in-a-row?)<br>> (disable-all)<br>> (send frame set-label (format "game's up: ~a won\n" who)))<br>> (set! turn (cdr turn))))<br>> ;; this last line uses the infinite list to switch turns <br>> <br>> <br></div>                                            </div></body>
</html>