2 ms·
You're thinking of a finite map, also called a hash table or a dictionary. The map function takes a function and a list and applies the function to every eleme
by hollerith 3y ago
You're thinking of a finite map, also called a hash table or a dictionary.
The map function takes a function and a list and applies the function to every element of the list:
map(double,[1,2,3]) = [2,4,6]
Grandparent could've used the for loop rather than the map function to make his point:
for i in [1,2,3]:
print i * 2
-- because in general instead of the i * 2 we might have a call to a function that might raise an exception.
ADDED. That is wrong: the for loop would not a good example at all because it is not customary to declare the type of a for loop or to need to declare which exceptions a `for` loop might throw.
- bsder 3y agoWhoops. Yeah, I wasn't thinking about map, fold, accumulate, etc. Thanks for the correction.