slow-starter

なにをやるにもslow start……。

茨城小旅行

茨城小旅行

週末にちょっと遠出。子供たちと茨城に行った。

いろいろと仕事関係で疲れた気持ちを吹っ切ってくれる、よい小旅行だったと思う。
牛久大仏の入り口の驚きの仕組みは、子供たちはちょっと怖がっていたけど…。

python_022

Haskellの真似

第2章 関数プログラミングのパラダイム―命令プログラミングと何が違うのか:[入門]関数プログラミング―質の高いコードをすばやく直感的に書ける!|gihyo.jp … 技術評論社

うえの記事を見ていて、「pythonでも同じようにプログラミングできるかな?」と気になった。ので、やってみた。

  • (きっと)普通なpython的な実装。
# test1.py
a = [10, 20, 30, 40, 50]
b = list(range(5))
c = list(zip(a, b))


def mul(x):
    return int(x[0])*int(x[1])


d = list(map(mul, c))
print(sum(d))
> python test1.py
400
# test2.py
def mul(x):
    return int(x[0])*int(x[1])

print(sum(list(map(mul, list(zip([10, 20, 30, 40, 50], range(5)))))))
> python test2.py
400

できた、かな…。
ただ、単純に読みにくくまとめただけのような気もする…。