Created
October 19, 2011 13:10
-
-
Save colwilson/1298238 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define the reduce function | |
# this function is called for every emit emitted | |
# from the map function above | |
# in this example we'll count all the fruit by | |
# type and also keep a tally for the baskets | |
reduceFunc = (key, values) -> | |
count = 0 | |
baskets = 0 | |
values.forEach (value) -> | |
count += value.count | |
baskets += value.baskets | |
return { | |
fruit: key, | |
count: count, | |
baskets: baskets | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment