Compact a for loop