6.01 Lecture Notes - List Comprehension, Mapreduce, Operand

6 views11 pages

Document Summary

>>> [first+last for (first, last) in zip(["hal", "jacob", "leslie"], Note that this last example is very di erent from this one: >>> [first+last for first in ["hal", "jacob", "leslie"] \ for last in ["abelson","white","kaelbling"]] Nested list comprehensions behave like nested for loops, the expression in the list comprehension is evaluated for every combination of the values of the variables. Here, we introduce three higher-order functions: map, reduce, and filter. The combination of these functions is a very powerful computational paradigm, which lets you say what you want to compute without specifying the details of the order in which it needs to be done. Google uses this paradigm for a lot of their computations, which allows them to be easily distributed over large numbers of cpus. See mapreduce: simpli ed data processing on large clusters, by je rey. You could write a special-purpose procedure: def halveelements(list): if list == []: return [] else: return [list[0]/2. 0] + halveelements(list[1:])

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Questions