Generalize compact to work on any Collection, not just Arrays.