Actually this looks more like set partitions than combinations to me. You are splitting up a set into smaller subsets, and order and size of subsets doesn't matter. There is some sample code for a set partition iterator in one of my nodes Re: Generator of integer partitionts of n for starters, and plenty of other places too, probably, if you super search with that term.