{"provider_url":"https://hatena.blog","blog_title":"inamori\u2019s diary","published":"2009-03-24 00:00:00","provider_name":"Hatena Blog","width":"100%","version":"1.0","blog_url":"https://inamori.hateblo.jp/","type":"rich","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Finamori.hateblo.jp%2Fentry%2F20090324%2Fp1\" title=\"reduce - 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>","url":"https://inamori.hateblo.jp/entry/20090324/p1","author_url":"https://blog.hatena.ne.jp/inamori/","image_url":null,"categories":["Python","C++"],"author_name":"inamori","height":"190","title":"reduce","description":"Python\u306b\u306freduce\u3068\u3044\u3046\u306e\u304c\u95a2\u6570\u304c\u3042\u3063\u3066\u9762\u767d\u3044\u3002 a = [ 1, 2, 3, 4 ]def add(x, y): return x + y sum = reduce(add, a) print sum # 10\u30e9\u30e0\u30c0\uff08\u7121\u540d\u95a2\u6570\uff09\u3092\u4f7f\u3063\u3066\u3082\u3044\u3044\u304c\u3001 sum = reduce(lambda x, y: x + y, a)\u305f\u3076\u3093\u4e0a\u306e\u307b\u3046\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3002 reduce(add, [ 1, 2, 3, 4 ]) = add(add(add(1, 2), 3), 4) = 1 + 2 + 3 + 4 = 10\u3068\u3044\u3046\u3053\u3068\u306e\u3088\u3046\u3060\u3002 min\u3060\u3068\u3001 a = [ 1, 2, 3, 4 ]def min\u2026"}