Do a map on list
counters = [1, 2, 3, 4] updated = [] for x in counters: updated.append(x + 10) # add 10 to each item print updated def inc(x): return x + 10 # function to be run print map(inc, counters) # collect results print map((lambda x: x + 3), counters) # function expression
1. | Map: lambda function inside | ||
2. | A sentence is split up into a list of words | ||
3. | Functional Programming Tools: map | ||
4. | Functional Programming Tools: map: More than one sequence may be passed | ||
5. | Use map |