Reduce() method

The following are characteristics of the reduce function, including examples of the input and output and the action the reduce method performs.
  • Input: Word and a list of its occurrences.
  • Output: A (word, total number of occurrences) pair.
  • Action: Sums together all counts that were output for a particular word.

Input data

WORD | LIST OF COUNTS
-----------+------------------
GreP | {1}
AbbA | {1}
DooR | {1,1}
MooN | {1,1}
SuN | {1,1,1}

Output data

WORD | TOTAL_COUNT
-----------+-------------
GreP | 1
AbbA | 1
DooR | 2
MooN | 2
SuN | 3