[plt-scheme] Fun with Unicode and delimited continuations

From: John Clements (clements at brinckerhoff.org)
Date: Thu Jun 3 19:47:59 EDT 2010

On Jun 3, 2010, at 4:33 PM, Matthias Felleisen wrote:

> 
> Can you return them from the function that grabs them (in Python)? 
> Can you resume the function once it has transfered control somewhere else? 
> Can you store the continuations in some vector? 
> 
> (I don't know the answers, but these are some of the things one can do with 1st-class values.) 

Yes:

def grabK () : yield 1 ; print "running..." ; yield 2

def grabAFewKonts () :
    return [grabK () , grabK ()]

a = grabAFewKonts();

f = a[0];
g = a[1];

print(f.next());
print(f.next());
print(g.next());


==>

pcp062805pcs:~/.ssh clements$ python /tmp/foo.py
1
running...
2
1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4669 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100603/fb8b7cb7/attachment.p7s>

Posted on the users mailing list.