Apr
15th
Tue
15th
a ruby one-liner by Justin
- >> a = ["a", "a", "a", "b", "b", "c", "d", "d"]
- >> a.uniq.map{|i| [i, a.select{|j| j==i}.length]}
- => [["a", 3], ["b", 2], ["c", 1], ["d", 2]]
Comments (View)
