Ruby Cheat Sheet

ruby

[1,2,3,4,5,6,7,1,3].group_by {|e| e}.map { |k, v| [k, v.size]}.to_h
python

import collections
dict(collections.Counter([1,2,3,4,5,6,7,1,3]))
javascript

[1, 2, 3, 4, 5, 6, 7, 1, 3].reduce((acc, x) => {
  if (!acc[x]) acc[x] = 0;
  acc[x] += 1;
  return acc;
}, {});
go

rust