Apply fn to lists of indexes generated from symbol counts. The counting is done so that the first symbol varies most quickly unless the optional direction parameter is set to :right.