On 08/06/2011 04:28 AM, Stephen Halter wrote:
Hi everyone,
I was reading through the wikipedia article on call/cc, and I thought
that playing around with some of the provided examples in DrRacket would
give me a better understanding of the feature. The second example was
how a python style generator could be created using call/cc
(http://en.wikipedia.org/wiki/Call-with-current-continuation#Examples).
I was looking how set! was used to update control-state's return
argument to the continuation referencing the most recent call to the
generator. I figured that if I removed the set! and called the generator
twice in a row, it would create an infinite loop of sorts since
control-state's return argument would forever hold a continuation
originating from the first call. However, this is not what happens when
I remove the set!. Instead it works exactly the same way it did before.
Any ideas why?
Thanks in advance for your help,
Stephen Halter
Below is the code that I where I don't (re)set! control-state's return
argument:
https://gist.github.com/1129202
> (generate-digit)
0
> (list (generate-digit) (generate-digit))
1
Hmmm.... I was expecting '(1 2)
Ryan
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users