Carte Réduisez et filtrez les fonctions dans Python
def function(a):
return a*a
x = map(function, (1,2,3,4)) #x is the map object
print(x)
print(set(x))
Jittery Jackal
def function(a):
return a*a
x = map(function, (1,2,3,4)) #x is the map object
print(x)
print(set(x))
def func(x):
if x>=3:
return x
y = filter(func, (1,2,3,4))
print(y)
print(list(y))
{16, 1, 4, 9}