LoginSignup
16
9

More than 5 years have passed since last update.

【備忘録】Python3でのreduce

Posted at

Python3では、reduce関数はグローバル名前空間から取り除かれてしまい、functoolsというモジュールに移動してしまいました。

こんな感じで使うようになりました。

>>> from functools import reduce
>>> reduce(lambda a,b:2*a+b,[1,0,1,1])
11
16
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
9