Last active
August 29, 2015 14:26
-
-
Save Deepwalker/ee61dc1a3ec86e8a4406 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
GET_KEY = lambda x: x[0] | |
def map_reduce(rows, mapper, reducer): | |
return ( | |
reducer(key, (row[1] for row in rows)) | |
for key, rows in groupby(sorted(mapper(rows), key=GET_KEY), GET_KEY) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment