Map
python的内置map功能
map(f, list)
def f(x):
return x*x
ex: r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])
Reduce
reduce(f, [x1, x2, x3, x4]) = f(f(f(x1, x2), x3), x4)
python的内置map功能
map(f, list)
def f(x):
return x*x
ex: r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])
reduce(f, [x1, x2, x3, x4]) = f(f(f(x1, x2), x3), x4)
本文标题:map/reduce
本文链接:https://www.haomeiwen.com/subject/japmyttx.html
网友评论