python/lambda_with_lists.py

11 lines
264 B
Python

def apply_func(func, list_of_lists):
return [func(*args) for args in zip(*list_of_lists)]
# Example usage:
if __name__ == "__main__":
list1 = [1, 2, 3]
list2 = [4, 5, 6]
result = apply_func(lambda x, y: x + y, [list1, list2])
print(result)