Wie lautet das Python-Äquivalent des folgenden Codes in Ruby?Python-Äquivalent von Fortsetzungen mit Ruby
def loop
cont=nil
for i in 1..4
puts i
callcc {|continuation| cont=continuation} if i==2
end
return cont
end
> c=loop
1
2
3
4
> c.call
3
4
Referenz: Secrets of lightweight development success, Part 9: Continuations-based frameworks
Es ist nicht so einfach, siehe http://stackoverflow.com/questions/312794/#313073 – jfs