You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2014-08-06-hadoop.md
+10-13Lines changed: 10 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -32,25 +32,20 @@ A MapReduce program is composed of a Map() procedure that performs filtering and
32
32
Map is the name of a higher-order function that applies a given function to each element of a list, returning a list of results. It is often called apply-to-all when considered in functional form. This is an example of functoriality.
33
33
34
34
For example, if we define a function square as follows:
35
-
35
+
```
36
36
square x = x * x
37
+
```
37
38
Then calling map square [1,2,3,4,5] will return [1,4,9,16,25], as map will go through the list and apply the function square to each element.
38
39
39
-
###Python
40
-
map(func, list1, list2, ...)
41
-
42
-
Returns a list in Python 2 and an iterator in Python 3.
43
-
44
-
###Scala
45
-
map: list.map(func)
46
-
map n list: (list1, list2, list3).zipped.map(func)
47
-
48
-
###Java 8+
49
-
stream.map(func)
40
+
|Language|Map |Map 2 lists |Map n lists |Note|
41
+
|---|---|---|---|---|
42
+
|Python|map(func,list)|map(func,list1,list2)|map(func,list1,list2,...)|Returns a list in Python 2 and an iterator in Python 3.|
43
+
|Scala|list.map(func)|(list1,list2).zipped.map(func)|(list1,list2,list3).zipped.map(func)|note: more than 3 not possible.|
44
+
|Java8|stream.map(func)||||
50
45
51
46
52
47
## [Reduce][Reduce_]
53
-
48
+
fold – also known variously as reduce, accumulate, aggregate, compress, or inject – refers to a family of higher-order functions that analyze a recursive data structure and recombine through use of a given combining operation the results of recursively processing its constituent parts, building up a return value. Typically, a fold is presented with a combining function, a top node of a data structure, and possibly some default values to be used under certain conditions. The fold then proceeds to combine elements of the data structure's hierarchy, using the function in a systematic way
54
49
55
50
|Language|Left fold |Right fold| Left fold without initial value | Right fold Right fold |
0 commit comments