Created
September 26, 2013 20:13
-
-
Save alloy-d/6719878 to your computer and use it in GitHub Desktop.
A hacky method for classifying things based on user input.
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
classify = ->(list, ider) do | |
groups = {} | |
list.each do |thing| | |
print "#{ider.call(thing)} " | |
(groups[gets.chomp.intern]||=[]) << thing | |
end | |
groups | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment