http://weblogs.mozillazine.org/roadmap/archives/2006/02/js_and_python_news.html ãã: js> function count(n) { for (var i = 0; i < n; i++) yield i; } js> g = count(10) [object Generator] js> g.next() 0 js> g.next() 1 js> two_to_nine = [i for i in g] 2,3,4,5,6,7,8,9 js> squares_to_20 = [i * i for i in count(20)] 0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361Pythonã«ããyieldã«ããgenerato
{{#tags}}- {{label}}
{{/tags}}