Last active
August 29, 2015 14:01
-
-
Save hoelzro/726b9980741c98c36c44 to your computer and use it in GitHub Desktop.
classify in Python
This file contains 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
# L is an iterable of some kind | |
# f is a transformation function | |
classification = collections.defaultdict(list) | |
for item in L: | |
classification[f(item)].append(item) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment