PYTHON
python anonymous function
def sum ( a, b ): # non anonymous
return a+b
print (sum(1, 2)) # 3
sum = lambda a,b: (a+b) # anonymous / lambda
print (sum(1, 2)) # 3
python anonymous function
# You have to save the lambda expresion for it to work
nameOfLambda = lambda arg1, arg2: expression
anonymous function python
#define a function inline
#(syntax) lambda parameter_list: expression parameter_list is comma separated
#lambda implicitly returns its expression's value, thus equivalent to any simple fxn of form...
'''
def function_name(parameter_list)
return expression
'''
numbers = [10, 3, 7, 1, 9, 4, 2, 8, 5, 6]
print(list(filter(lambda x: x%2 != 0, numbers))) #here filter() takes a fxn as 1st argument
# [3, 7, 1, 9, 5]
python anonymous function
def sum ( a, b ): # non anonymous
return a+b
print (sum(1, 2)) # 3
sum = lambda a,b: (a+b) # anonymous / lambda
print (sum(1, 2)) # 3
python anonymous function
# You have to save the lambda expresion for it to work
nameOfLambda = lambda arg1, arg2: expression
anonymous function python
#define a function inline
#(syntax) lambda parameter_list: expression parameter_list is comma separated
#lambda implicitly returns its expression's value, thus equivalent to any simple fxn of form...
'''
def function_name(parameter_list)
return expression
'''
numbers = [10, 3, 7, 1, 9, 4, 2, 8, 5, 6]
print(list(filter(lambda x: x%2 != 0, numbers))) #here filter() takes a fxn as 1st argument
# [3, 7, 1, 9, 5]