in reply to How to get all combinations

I think that something in Algorithm:Combinatorics will help you.