Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import reduce
- funs = [
- lambda x: x + 1,
- lambda x: x * 2,
- lambda x: x / 3,
- lambda x: x ** 4,
- ]
- operands = [4, 5, 6, 2]
- def zip_():
- return list(map(lambda x: x[0](x[1]), zip(funs, operands)))
- def reduce_():
- itfuns = iter(funs)
- return reduce(lambda acc, x: acc.append(
- next(itfuns)(x)) or acc, operands, [])
- print(zip_())
- print(reduce_())
- # [5, 10, 2.0, 16]
- # [5, 10, 2.0, 16]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement