in reply to Counting elements being mapped via map{}

If a rule only applies to the last element, there's no reason to apply it to every element. Take it out of the map