###reduce_test 函数######################
# num_1 = [1,2,3,100]
# def reduce_test(func,array,init=None):
# if init is None:
# res = array.pop(0)
# else:
# res = init
# for num in array:
# res = func(res,num)
# return res
# ss = reduce_test(lambda x,y:x*y,num_1,2)
# print(ss)
###reduce 函数:
from functools import reduce
num_1 = [1,2,3,100]
res = reduce(lambda x,y:x+y,num_1,100)
print(res)
相关文章
- 03-24控制reduce端缓冲大小以避免OOM
- 03-24js Array.prototype.reduce API的理解
- 03-24reduce 求数组里每个元素出现的次数(价值50块钱的题目)
- 03-24map,shuffer,reduce阶段任务
- 03-24reduce函数
- 03-24面试官问:UDF是在Map端执行还是Reduce端执行?
- 03-248个例子轻松学会js的reduce用法,和reduce的骚操作
- 03-24python – 有没有办法将函数存储在列表或字典中,以便在调用索引(或键)时触发存储的函数?
- 03-24使用reduce实现随想转数组,数组转对象
- 03-24scanf函数和printf函数