Functional Programming Tools: map : Functional Programming « Function « Python






Functional Programming Tools: map

Functional Programming Tools: map
# "map(function, sequence)" calls function(item) for each of the sequence's 
# items and returns a list of the return values. For example, to compute some 
# cubes:

def cube(x): return x*x*x

print map(cube, range(1, 11))
           
       








Related examples in the same category

1.Functional Programming Tools: map: More than one sequence may be passedFunctional Programming Tools: map: More than one sequence may be passed
2.Functional Programming Tools: reduceFunctional Programming Tools: reduce
3.Functional Programming Tools: reduce 2Functional Programming Tools: reduce 2
4.Functional Programming Tools: filterFunctional Programming Tools: filter