{"published":"2010-03-08 00:00:00","version":"1.0","categories":["PE","C++"],"author_name":"inamori","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Finamori.hateblo.jp%2Fentry%2F20100308%2Fp1\" title=\"Project Euler 2\uff081\uff09 - inamori\u2019s diary\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","width":"100%","provider_name":"Hatena Blog","type":"rich","url":"https://inamori.hateblo.jp/entry/20100308/p1","provider_url":"https://hatena.blog","height":"190","blog_url":"https://inamori.hateblo.jp/","author_url":"https://blog.hatena.ne.jp/inamori/","image_url":null,"blog_title":"inamori\u2019s diary","title":"Project Euler 2\uff081\uff09","description":"http://projecteuler.net/index.php?section=problems&id=2 Haskell\u306a\u3089\u3053\u3046\u3002 fib = 1:2:[ a + b | (a, b) <- zip fib (tail fib) ] main = print (sum (filter even (takeWhile (<= 4 * 10^6) fib))) filter\u3068\u540c\u69d8\u306btakewhile\u3092\u4f5c\u308b\u3002 template<typename T, typename U, typename V> class takewhile { T pred; U obj; public: takewhi\u2026"}