Before I get on and create something inefficient and bloated, I just want to check for anything elegant and beautiful that I’ve been unable to find so far.
And in any case, it is too beautiful, and also quite clear, to the extent that even people relatively unfamiliar with Julia may just understand the code.
So we clearly need to make it uglier, eg
f(A) = (d = Dict(); (a -> d[a] = get(d, a, 0) + 1).(A))
By the way, the (unwritten) rules of the competition are:
it should do something well,
but have a subtle potential bug (as pointed out by @non-Jedi — if broadcasting does not ensure sequential mapping, a lot of code will break, hopefully non-deterministically),
have enough punctuation to complete an e e cummings poem to fully formed sentences.
This is very confusing, I have no idea how the f got there. I tested different versions (including yours, but I deemed it too beautiful for the public eye) and benchmarked them and everything, yet somehow I got it wrong when copying it. Is this Muphry’s law at work?