{"categories":["Python"],"html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmelpon.hatenadiary.org%2Fentry%2F20121221%2F1356051760\" title=\"yield \u306e\u623b\u308a\u5024\u3092\u53d7\u3051\u53d6\u308b - melpon\u65e5\u8a18 - Haskell\u3082C++\u3082\u307e\u3068\u3082\u306b\u6271\u3048\u306a\u3044\u3078\u305f\u308c\u306e\u30da\u30fc\u30b8\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","author_name":"melpon","width":"100%","author_url":"https://blog.hatena.ne.jp/melpon/","published":"2012-12-21 10:02:40","url":"https://melpon.hatenadiary.org/entry/20121221/1356051760","provider_url":"https://hatena.blog","description":"\u3053\u306e\u8a18\u4e8b\u306f Python Tips Advent Calendar 2012 \uff12\uff11\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002 yield \u306e\u547c\u3073\u51fa\u3057\u306b\u306f\u623b\u308a\u5024\u304c\u3042\u308a\u307e\u3059\u3002 \u666e\u6bb5\u306f None \u3067\u3059\u304c\u3001\u547c\u3073\u51fa\u3057\u5143\u304c send \u95a2\u6570\u3092\u4f7f\u3063\u305f\u5834\u5408\u3001\u305d\u306e\u5f15\u6570\u304c yield \u306e\u623b\u308a\u5024\u3068\u3057\u3066\u6e21\u3055\u308c\u307e\u3059\u3002 >>> def f(xs): ... n = None ... for x in xs: ... if n is None or n == 0: ... n = yield x ... else: ... n -= 1 >>> it = f([1,2,3,4,5,6,7,8,9]) >>> it.next() 1 >>> it.se\u2026","blog_url":"https://melpon.hatenadiary.org/","image_url":null,"title":"yield \u306e\u623b\u308a\u5024\u3092\u53d7\u3051\u53d6\u308b","type":"rich","version":"1.0","height":"190","blog_title":"melpon\u65e5\u8a18 - Haskell\u3082C++\u3082\u307e\u3068\u3082\u306b\u6271\u3048\u306a\u3044\u3078\u305f\u308c\u306e\u30da\u30fc\u30b8","provider_name":"Hatena Blog"}