Skip to content

Instantly share code, notes, and snippets.

@Deepwalker
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deepwalker/ee61dc1a3ec86e8a4406 to your computer and use it in GitHub Desktop.
Save Deepwalker/ee61dc1a3ec86e8a4406 to your computer and use it in GitHub Desktop.
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