def countby(key, seq):
 if (not callable(key)):
  key = getter(key)
 return frequencies(map(key, seq))

def countby ( key , seq ) : if ( not callable ( key ) ) : key = getter ( key ) return frequencies ( map ( key , seq ) )
count elements of a collection by a key function .