'''
Lambda functions are small functions that are very useful.
They take in as many attributes but only have 1 expression and you only
need 1 line to create them.
'''
# Writing a normal function
def add(a, b):
return a + b
# Writing a lambda function
add = lambda a, b: a + b
# You can use lambda functions as anonymous functions inside functions
def multiplier(n):
return lambda a: a * n
my_doubler = multiplier(2)
print(my_doubler(4)) # 8
print(my_doupler(5)) # 10
>>> list(map(lambda x, y: x - y, [2, 4, 6], [1, 3, 5]))
[1, 1, 1]
>>> list(map(lambda x, y, z: x + y + z, [2, 4], [1, 3], [7, 8]))
[10, 15]