1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- from typing import Callable
- def apply(func, objects):
- return [func(x) for x in objects]
- def compute(func_list, *args):
- return [func(x) for func in func_list for x in args]
- def compute_new(func_list, *args):
- lst = []
- value = 0
- for x in args:
- value = x
- for func in func_list:
- value = func(value)
- lst.append(value)
-
- return lst
- def filter_list(f: Callable, lst: list):
- pass
- """Для теста"""
- def square(num):
- return num ** 2
- def inc(num):
- return num + 1
- def dec(num):
- return num - 1
- def main():
- print(compute([inc, dec, square], 10, 20, 30, 40))
- print(compute_new([inc, square, dec], 10, 20, 30, 40))
- if __name__ == '__main__':
- main()
|