Add 'frequencies' function

Nice and short, this is your own version from your blog.  We can do it iteratively too using defaultdict -- let me know if you prefer that.