Course of python developer in 2020 (Functional programming)
Map() Filter() Zip() Reduce()
Map()
Refer to #136
name_1=[List of number]
def action(x):
return function of the action(say, x*2)
Print (list(map(action, list of number)))
print(name_1)
--------------------------------------------------------------------------
Filter()
Refer to #137
name_1=[List of number]
def condition(x):
return function of the condition (say, x%2!=0)
Print (list(filter(condition, list of number)))
print(name_1)
--------------------------------------------------------------------------
Zip()
Refer to #138
List_1=[x, y, z]
List_2=(a,b,c)
List_3=(A,B,C)
print(list(zip(List_1, List_2, List,3)
--------------------------------------------------------------------------
Reduce()
Refer to #139
from functools import reduce
List_1=[List of number]
def action_name(a,b):
return function
Print(reduce(action_name, List_1, Start number))
Example:
Comments
Post a Comment