{"width":"100%","url":"https://blog.emattsan.org/entry/2024/12/31/060000","blog_url":"https://blog.emattsan.org/","title":"Ruby\u3067unfold\u3092\u66f8\u304f","height":"190","categories":["Elixir","Ruby"],"html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.emattsan.org%2Fentry%2F2024%2F12%2F31%2F060000\" title=\"Ruby\u3067unfold\u3092\u66f8\u304f - \u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u7684\u611b\u60c5\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_url":"https://hatena.blog","author_url":"https://blog.hatena.ne.jp/E_Mattsan/","image_url":"https://cdn.user.blog.st-hatena.com/default_entry_og_image/401695/1514192717173017","provider_name":"Hatena Blog","description":"\u7279\u5b9a\u306e\u5024\u304b\u3089\u51fa\u767a\u3057\u3066\u6f14\u7b97\u3092\u7e70\u308a\u8fd4\u3057\u5024\u306e\u4e26\u3073\u3092\u51fa\u529b\u3059\u308b unfold \u3002 \u305d\u3046\u3044\u3048\u3070 Ruby \u306b unfold \u3063\u3066\u306a\u3044\u3093\u3060\u3063\u3051\uff1f \u3068\u3044\u3046\u306e\u304c\u767a\u7aef\u3002 unfold \u3068\u306f \u65e9\u3044\u8a71\u304c fold \u306e\u9006\u3067\u3059\u3002 Elixir \u3067\u306f Stream.unfold/2 \u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002 # 1 \u304b\u3089\u59cb\u3081\u3066\u3001\u524d\u306e\u5024\u306b 1 \u3092\u52a0\u3048\u308b Stream.unfold(1, fn x -> {x, x + 1} end) |> Enum.take(10) #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # 1 \u304b\u3089\u59cb\u3081\u3066\u3001\u524d\u306e\u5024\u3092 2 \u500d\u306b\u3059\u308b Stream.unfold(1, fn x ->\u2026","published":"2024-12-31 06:00:00","blog_title":"\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u7684\u611b\u60c5","type":"rich","version":"1.0","author_name":"E_Mattsan"}